Open strottos opened 3 years ago
If it's helpful, I had to implement something like this recently.
tokio does not depend on nix
at all today, but fwiw it can be done with a libc::kill
call as well (though you should take care to not cache the child PID and only signal if child.id().is_some()
, else it is possible to signal some other process if the pid got recycled).
If such an API was to be added it would probably need to be OS specific since the signal semantics (outside of killing the process outright) break down with Windows
I did a brief research about how we could implement this for Windows.. I don't develop in Windows so they are assumptions:
kill
doesn't seem available for windowsIn short, for POSIX signals, It should be a problem but for Windows... I seems tricky
If I spawn a child process using Tokio, e.g.
then it would be helpful to be able to send a signal to that child process of my choosing. Something along the lines of:
My understanding is that signal sending is non-blocking (or at least a very fast syscall) so that this can be done using something from the
nix
crate say (which I think the process flag in Tokio brings in already, but I could be wrong).You may need to consider what to do on Windows with this as well. Maybe these calls can just be ignored there, I'm not sure what's best offhand.