Skip to content
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

Command::detach can cause zombie processes #17176

Closed
carllerche opened this issue Sep 11, 2014 · 4 comments
Closed

Command::detach can cause zombie processes #17176

carllerche opened this issue Sep 11, 2014 · 4 comments

Comments

@carllerche
Copy link
Member

Properly spawning a detached process requires double forking in order to avoid zombie processes:

http://www.linuxjedi.co.uk/2014/02/why-use-double-fork-to-daemonize.html

I did not see this happening in https://github.com/rust-lang/rust/blob/master/src/libnative/io/process.rs

cc @aturon @alexcrichton

@aturon
Copy link
Member

aturon commented Sep 11, 2014

I'd be glad to take a look at this.

Is this a blocking issue for skylight?

@carllerche
Copy link
Member Author

Our requirements are pretty simple, so we are going to just bind http://man7.org/linux/man-pages/man3/daemon.3.html for now. Our parent process stays around for a while and could repeatedly spawn of daemons so zombies would be a pretty bad thing in our case.

@steveklabnik
Copy link
Member

I wonder how this sorted out with the IO RFC.

@alexcrichton
Copy link
Member

This was removed from Command (partly for the reasons stated here) and we should be able to add the option backwards-compatibly to Command. This issue specifically, however, I'm going to close as it's no longer relevant. I'm sure it will definitely come back up when re-adding the option, however!

bors added a commit that referenced this issue Aug 4, 2015
Add a new method `CommandExt::session_leader(&mut self, on: bool)` to create a new session (cf. `setsid(2)`) for the child process. This means that the child is the leader of a new process group. The parent process remains the child reaper of the new process.

This is not enough to create a daemon process. The *init* process should be the child reaper of a daemon. This can be achieved if the parent process exit. Moreover, a daemon should not have a controlling terminal. To acheive this, a session leader (the child) must spawn another process (the daemon) in the same session.

cc rust-lang/rfcs#941
cc #17176
lnicola pushed a commit to lnicola/rust that referenced this issue May 19, 2024
Fix impl trait params not being counted properly

Fixes the other thing in rust-lang/rust-analyzer#17173, this just rolls back a change from rust-lang/rust-analyzer#17175 and adds a comment as to what it does
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

No branches or pull requests

4 participants