xxxxxxxxxx
import core.sys.posix.signal;
import std.concurrency;
import std.datetime : seconds;
import std.process;
void main()
{
sigset_t ss;
sigemptyset(&ss);
sigaddset(&ss, SIGINT);
pthread_sigmask(SIG_BLOCK, &ss, null);
auto pid = spawnProcess(["sleep", "infinity"]);
scope(failure) {
kill(pid, SIGKILL);
wait(pid);
}
// kill the spawned process with SIGINT
// and send its return code
spawn((shared Pid pid) {
auto p = cast()pid;
kill(p, SIGINT);
auto code = wait(p);
assert(code < 0);
send(ownerTid, code);
}, cast(shared)pid);
auto received = receiveTimeout(3.seconds,
(int) {
assert(true);
},
);
assert(received);
}