Skip to content
New issue

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

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

Already on GitHub? # to your account

Is it possible to generate a warning about std::process::Command::spawn() returned Child is never waited? #10754

Closed
Originalimoc opened this issue May 6, 2023 · 0 comments · Fixed by #11476
Labels
A-lint Area: New lints

Comments

@Originalimoc
Copy link

What it does

If there is no wait on the Child handle(and/or before it goes out of scope, the destructor won't wait() it either.), generate a warning about possible consequences: zombie process.

Lint Name

process_child_not_waited

Category

No response

Advantage

No response

Drawbacks

None.

Example

thread::spawn(move || {
                std::process::Command::new(&command[0])
                .args(&command[1..])
                .spawn()
                .unwrap_or_else(|e| panic!("Failed to execute {}: {}", command.join(" "), e));
            });

Could be written as:

thread::spawn(move || {
                let child = std::process::Command::new(&command[0])
                .args(&command[1..])
                .spawn()
                .unwrap_or_else(|e| panic!("Failed to execute {}: {}", command.join(" "), e));
                child.wait();
            });
@Originalimoc Originalimoc added the A-lint Area: New lints label May 6, 2023
@bors bors closed this as completed in 9e260ff Aug 28, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-lint Area: New lints
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant