Skip to content

"spawned process is not wait()ed on in all code paths" when ? used in chain call before spawn() #14911

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

Closed
lyskov opened this issue May 28, 2025 · 2 comments · Fixed by #14912
Closed
Assignees
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@lyskov
Copy link

lyskov commented May 28, 2025

Summary

Clippy flag command.spawn() code when ? used in daisy-chain calls before the spawn got called and .expect used on spawn invocation.

Interestingly, changing expect to ? on spawn() clear the the error:

fn test_1_passed() -> std::io::Result<String> {
    let (mut recv, send) = std::io::pipe()?;
    let mut command = Command::new("ls").stdout(send.try_clone()?).spawn()?;
    command.wait()?;
    Ok("".into())
}

Lint Name

clippy::zombie_processes

Reproducer

I tried this code:

fn test_1_flagged() -> std::io::Result<String> {
    let (mut recv, send) = std::io::pipe()?;
    let mut command = Command::new("ls")
    .stdout(send.try_clone()?)
    .spawn().expect("Could not spawn new process...");
    command.wait()?;
    Ok("".into())
}

I expected to see this happen: no issue

Instead, this happened: "spawned process is not wait()ed on in all code paths" highlighting send.try_clone()? as offending part.

Version

rustc 1.87.0 (17067e9ac 2025-05-09)
binary: rustc
commit-hash: 17067e9ac6d7ecb70e50f92c1944e545188d2359
commit-date: 2025-05-09
host: aarch64-apple-darwin
release: 1.87.0
LLVM version: 20.1.1
@lyskov lyskov added C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't labels May 28, 2025
@samueltardieu
Copy link
Contributor

@rustbot label -I-false-negative +I-false-positive
@rustbot claim

@rustbot rustbot added I-false-positive Issue: The lint was triggered on code it shouldn't have and removed I-false-negative Issue: The lint should have been triggered on code, but wasn't labels May 28, 2025
@lyskov
Copy link
Author

lyskov commented May 28, 2025

Thank you for looking this up @samueltardieu !

github-merge-queue bot pushed a commit that referenced this issue Jun 3, 2025
If an early return is found under the HIR local declaration node but
before the child process is created, it should not trigger the lint
because the child process has not yet been created.

changelog: [`zombie_process`]: do not complain about early early returns

Fixes #14911
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants