Spawning a process, then killing it on SIGINT

aliak something at something.com
Sat Nov 23 09:54:48 UTC 2019


Is there a way to go about killing a process after spawning it on 
a SIGINT?

I can't do this for e.g. because kill is not @nogc.

Pid currentSpawnedPid;
extern(C) void killCurrentPidHandler(int sig) nothrow @nogc 
@system {
   kill(currentSpawnedPid, sig);
}

int main() {
   currentSpawnedPid = spawnProcess(["docker-compose", "up"], 
stdin, stdout, stderr);
   signal(SIGINT, &killCurrentPidHandler);
   return wait(currentSpawnedPid);
}

Any other ways to go about this?

Cheers,
- Ali


More information about the Digitalmars-d-learn mailing list