You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This one is painful to look at. The test case below tries to open /proc/<pid>/stat on a process that is just about to die. I'd call the whole construct "broken", but it exists.
You can make an awfully strong case that the child process isn't guaranteed to be alive at the point the stat file is opened in the parent, but for reasons, this always seems to be the case on Real Linux™. WSL strace here and Linux strace here. Don't dwell on the straces though; the error is No such file or directory on /proc/pid/stat because that process is gone.
[edit- delete poor speculation]. Whatever the reason, it isn't dumb luck; you can uncomment the sleep() call after the else, but no matter how long you hang around, the proc/<pid> entry is still there long after the child /bin/echo process has had a chance to finish. 14959.
Thanks for reporting the issue. This is a known issue where procfs in WSL does not handle zombie processes correctly. Can you please let us know what scenario this is blocking so we can prioritize?
I linked the scenario in it exists above. It's how the chromium base library gets the parent process id of a given process id, independent of parent/child relationship of the caller. [There's no explicit posix construct for such a thing.]
fwiw, indeed it isn't dumb luck that the process entry is still around after the process exits. Until a call to waitpid() from the parent process (presuming the parent process is still around and SIGCHILD doesn't get kicked up to init), Real Linux keeps the process structure around in the kernel (leading to a "zombie" process which has exited but remains visible in process managers).
Activity
stehufntdev commentedon Nov 14, 2016
Thanks for reporting the issue. This is a known issue where procfs in WSL does not handle zombie processes correctly. Can you please let us know what scenario this is blocking so we can prioritize?
therealkenc commentedon Nov 14, 2016
I linked the scenario in it exists above. It's how the chromium base library gets the parent process id of a given process id, independent of parent/child relationship of the caller. [There's no explicit posix construct for such a thing.]
Brian-Perkins commentedon Jul 11, 2018
This should work better starting in Insider Build 17713
therealkenc commentedon Jul 11, 2018
Brian - #2786 too then probably (it was almost duped)
Brian-Perkins commentedon Jul 11, 2018
therealkenc -- agreed, added a comment there as well.
mqudsi commentedon Sep 29, 2018
fwiw, indeed it isn't dumb luck that the process entry is still around after the process exits. Until a call to
waitpid()from the parent process (presuming the parent process is still around andSIGCHILDdoesn't get kicked up toinit), Real Linux keeps the process structure around in the kernel (leading to a "zombie" process which has exited but remains visible in process managers).Keep keepalive code under WSL for a while longer