Discover pid of Child using std::process:::Command


Is there any way of discovering the process id (presumably not portably) for a Child generated by std::process::Command? I want to record the PID in a file (so later I can discover if it is still running and kill it).

I suppose as a workaround I could record the ID of the parent process, but then I need to listen for signals and kill the child and clean up. Not the end of the world, but definitely a nuisance… and it also prevents me from waiting on the child, so I’d be forced to use polling, which is both ugly and inefficient.


Okay, I see how to do this, and feel silly for even asking.

I searched for “pid” not even thinking that it might be called something different!