-
Notifications
You must be signed in to change notification settings - Fork 13.3k
std: Support consuming a Process without waiting #14551
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
Conversation
|
||
/// Forgets this process, allowing it to outlive the parent | ||
/// | ||
/// This function will forcefully prevent calling `wait()` on the child |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What makes it forceful?
Do we actually want to leave stdin/stdout/stderr/extra_io open? I assumed we'd just want to avoid calling Also, this doesn't really daemonize the process. It just allows the child to outlive the |
To clarify, daemonization is typically assumed to involve things like ignoring SIGHUP, and perhaps adopting a new process group. |
This doesn't leave the I/O handles open, the function here consumes the type and the drop glue will take over after we canceled our own destructor, closing all the handles. I suppose I use the term daemon for any long-running process, so I'm not too familiar with any specific connotations it has. Do you have a suggestion for an alternate name to use? The name |
Ah, you're right, they'll close automatically. I was fooled by the fact that the How about |
According to wikipedia, "a daemon is a computer program that runs as a background process, rather than being under the direct control of an interactive user", which sounds like what this is doing. What do others think about the name |
|
Perhaps |
Regardless of the definition, I feel that 'daemonize' is fairly jargony (and clearly open to interpretation). |
Pushed with a renaming of the method to |
ping r? |
Forking off a child which survives the parent is often a useful task, and is currently not possible because the Process type will invoke `wait()` in its destructor in order to prevent leaking resources. This function adds a new safe method, `forget`, which can be used to consume an instance of `Process` which will then not call `wait` in the destructor. This new method is clearly documented as a leak of resources, but it must be forcibly opted in to. Closes rust-lang#14467
Forking off a child which survives the parent is often a useful task, and is currently not possible because the Process type will invoke `wait()` in its destructor in order to prevent leaking resources. This function adds a new safe method, `daemonize`, which can be used to consume an instance of `Process` which will then not call `wait` in the destructor. This new method is clearly documented as a leak of resources, but it must be forcibly opted in to. Closes #14467
…stable, r=Veykril Fix faulty variable extraction Followup to rust-lang#14549 Fixes rust-lang/rust-analyzer#14549 (comment) and rust-lang/rust-analyzer#14549 (comment)
Forking off a child which survives the parent is often a useful task, and is
currently not possible because the Process type will invoke
wait()
in itsdestructor in order to prevent leaking resources. This function adds a new safe
method,
daemonize
, which can be used to consume an instance ofProcess
whichwill then not call
wait
in the destructor.This new method is clearly documented as a leak of resources, but it must be
forcibly opted in to.
Closes #14467