- Home /
Linux Headless -- Application.Quit() doesn't work?
Hi,
I'm working on a real time multiplayer game where the servers are unity instances running on Linux (Ubuntu 12.04 LTS.) Unity 4.2's promise of a working headless mode for Linux had me quite excited, and early testing seems great (no xvfb dependency, massively reduced CPU utilization) but I'm having one issue:
Application.Quit() doesn't seem to work in Headless mode.
Is this working as intended? I use Application.Quit() in the server code to exit the process once a game is completed but this no longer works.
I've attached a sample project demonstrating the issue. It's really quite trivial but if you build in headless mode the process does not exit. If you build without headless mode the process exists as expected.
Answer by Schubkraft · Aug 15, 2013 at 09:45 AM
This is currently a bug in Unity. Sorry.
Try using System.Diagnostics.Process.GetCurrentProcess().Kill(); in the meantime.
Thanks for the answer!
I filed a bug report shortly after asking the question it was confirmed and can be viewed here: https://fogbugz.unity3d.com/default.asp?556483_89f4a1i8t6dh18oh (so others might know when it gets fixed.)
I confirm that this workaround works, although it's a bit of a sledgehammer effect, and causes your OnApplicationQuit() not to be called first. I hope that UT will be fixing this soon!
Wouldn't System.Environment.Exit()
be a better solution?
System.Environment.Exit() is unreliable for me. It usually gets stuck after trying to tgkill() some thread, but weirdly, it does it only in Docker. GetCurrentProcess().$$anonymous$$ill() works for me.
Your answer
Follow this Question
Related Questions
Linux game server 1 Answer
Unity networking tutorial? 6 Answers
What does the headless build option do? 3 Answers
Networking with Linux 1 Answer
How to remove unneeded references (texture, audio) when doing headless server builds? 2 Answers