diff options
| author | Corey Richardson <corey@octayn.net> | 2014-12-05 10:07:02 -0800 |
|---|---|---|
| committer | Corey Richardson <corey@octayn.net> | 2014-12-05 10:07:02 -0800 |
| commit | 64d58dcac2e57bd93c868ea9d49a8b877e1be5df (patch) | |
| tree | d25b9a9ee5e18c50136274b5046459d6251cdf91 /src/rustllvm/RustWrapper.cpp | |
| parent | ea8bb5d18d6bfff644631a1692eea1e429566298 (diff) | |
| parent | 74fb798a200dc82cf5b4a18065e3ea565229adc3 (diff) | |
| download | rust-64d58dcac2e57bd93c868ea9d49a8b877e1be5df.tar.gz rust-64d58dcac2e57bd93c868ea9d49a8b877e1be5df.zip | |
rollup merge of #19454: nodakai/libstd-reap-failed-child
After the library successfully called `fork(2)`, the child does several
setup works such as setting UID, GID and current directory before it
calls `exec(2)`. When those setup works failed, the child exits but the
parent didn't call `waitpid(2)` and left it as a zombie.
This patch also add several sanity checks. They shouldn't make any
noticeable impact to runtime performance.
The new test case in `libstd/io/process.rs` calls the ps command to check
if the new code can really reap a zombie.
The output of `ps -A -o pid,sid,command` should look like this:
```
PID SID COMMAND
1 1 /sbin/init
2 0 [kthreadd]
3 0 [ksoftirqd/0]
...
12562 9237 ./spawn-failure
12563 9237 [spawn-failure] <defunct>
12564 9237 [spawn-failure] <defunct>
...
12592 9237 [spawn-failure] <defunct>
12593 9237 ps -A -o pid,sid,command
12884 12884 /bin/zsh
12922 12922 /bin/zsh
...
```
where `./spawn-failure` is my test program which intentionally leaves many
zombies. Filtering the output with the "SID" (session ID) column is
a quick way to tell if a process (zombie) was spawned by my own test
program. Then the number of "defunct" lines is the number of zombie
children.
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
