Ctrl+C doesn't interrupt running tasks (some I/O in infinite loop inside) and runEventLoop() doesn't return.
Am 13.07.2015 um 15:02 schrieb Jack Applegame:
Ctrl+C doesn't interrupt running tasks (some I/O in infinite loop inside) and runEventLoop() doesn't return.
By default it does (well, it just terminates running tasks,
unfortunately, instead of using Task.interrupt()
). Do you have any
more information?
On Mon, 13 Jul 2015 15:17:12 +0200, Sönke Ludwig wrote:
Do you have any more information?
After pressing Ctrl+C "Received signal 2. Shutting down." appears, but application seems continuing work - tasks do I/O and print logs.
Unfortunately, I can't reproduce that behaviour on a simple project.
On Mon, 13 Jul 2015 13:02:57 GMT, Jack Applegame wrote:
Ctrl+C doesn't interrupt running tasks (some I/O in infinite loop inside) and runEventLoop() doesn't return.
Perhaps related to http://forum.rejectedsoftware.com/groups/rejectedsoftware.vibed/thread/25872/ ?
I have similar issues when I spawn my own background-threads.
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.
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.
OS Linux x64, vibe-d 0.7.24-beta.3, compiler DMD 2.067.1
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...
On Tue, 14 Jul 2015 13:08:51 +0200, Sönke Ludwig wrote:
Does it also continue after pressing Ctrl+C twice in that case?
Yes it does. It continues to work regardless of the number of pressings Ctrl+C and every time after pressing prints "Received signal 2. Shutting down.".
Only way to stop the application is send SIGKILL signal.