Skip to content

tests: fix clippy::zombie_processes finding #467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 27, 2024

Conversation

cpu
Copy link
Member

@cpu cpu commented Sep 27, 2024

Nightly clippy's clippy::zombie_processes lint flagged the following:

error: spawned process is never `wait()`ed on
   --> tests/client_server.rs:285:26
    |
285 |         let mut server = self.server_opts.run_server();
    |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: consider calling `.wait()`
    = note: not doing so might leave behind zombie processes
    = note: see https://doc.rust-lang.org/stable/std/process/struct.Child.html#warning
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#zombie_processes

While we do call kill() on the process, we weren't wait()ing it. The process::Child docs have a warning:

On some systems, calling wait or similar is necessary for the OS to
release resources. A process that terminated but has not been waited on
is still around as a “zombie”. Leaving too many zombies around may
exhaust global resources (for example process IDs).

So it seems it may not be sufficient on all systems to kill() without wait().

Let's add a wait() just to be sure. Nobody likes zombies.

Nightly clippy's `clippy::zombie_processes` lint flagged the following:

```
error: spawned process is never `wait()`ed on
   --> tests/client_server.rs:285:26
    |
285 |         let mut server = self.server_opts.run_server();
    |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: consider calling `.wait()`
    = note: not doing so might leave behind zombie processes
    = note: see https://doc.rust-lang.org/stable/std/process/struct.Child.html#warning
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#zombie_processes
```

While we _do_ call `kill()` on the process, we weren't `wait()`ing it.
The `Process::Child` docs have a warning:

  On some systems, calling wait or similar is necessary for the OS to
  release resources. A process that terminated but has not been waited on
  is still around as a “zombie”. Leaving too many zombies around may
  exhaust global resources (for example process IDs).

So it seems it may not be sufficient on all systems to `kill()` without
`wait()`.

Let's add a `wait()` just to be sure. Nobody likes zombies.
@cpu cpu merged commit c6d5b7e into rustls:main Sep 27, 2024
38 checks passed
@cpu cpu deleted the cpu-shop-smart-shop-s-mart branch September 27, 2024 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants