py-spy icon indicating copy to clipboard operation
py-spy copied to clipboard

"Error: No child process (os error 10)" Race condition: PID is pruned by the time main thread checks on it

Open ramonwirsch opened this issue 8 months ago • 1 comments

For profiling with a command line, the sampler thread notices that the process-under-observation died and stops sampling. Main thread finishes processing all samples, but will later attempt to try_wait() for said process to terminate again.

On ARM systems (Raspberry Pi 5 among others), Linux has already cleaned the PID by then, leading to this error message. All other outputs have already been successfully written by then, so this just causes the exit code and the errand error message.

It seems, the code should not attempt to lookup the PID in another thread, but carry the info on the process terminating via the sampler object only.

ramonwirsch avatar Apr 09 '25 09:04 ramonwirsch

I see this in amd64 systems as well (kernel 6.1).

danielkza avatar Sep 05 '25 14:09 danielkza