Am 14.07.2015 um 11:37 schrieb Jack Applegame:
I found the reason. Look at this funny code
import vibe.d; import std.stdio; void main() { runTask({ while(true) { sleep(5.seconds); logInfo("working"); } }).join; // this point will never be reached runEventLoop(); }
After pressing Ctrl+C we exit to console, but program continues working in background like daemon.
Does it also continue after pressing Ctrl+C twice in that case? I'm not
sure about Linux now, but on Windows, although the keyboard input is
back to the command interpreter, a Ctrl+C will still go to the old process.
Workaround is simple - don't use
join()
before running event loop:import vibe.d; import std.stdio; void main() { runTask({ runTask({ while(true) { sleep(5.seconds); logInfo("working"); } }).join; }); runEventLoop(); }
But that daemonization looks strange.
It behaved like that as long as I remember. I simply assumed that this
behavior is somehow specific to the console, but maybe I'm just doing
something stupid in the signal handler...