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

using "run()" - child processes persist after parent exits. #9095

Open
amitmurthy opened this issue Nov 21, 2014 · 2 comments
Open

using "run()" - child processes persist after parent exits. #9095

amitmurthy opened this issue Nov 21, 2014 · 2 comments
Labels
docs This change adds or pertains to documentation

Comments

@amitmurthy
Copy link
Contributor

If I start a child julia process like this:

julia> @schedule begin
         run(`julia -e "while true; sleep(1); end"`)
       end
Task (waiting) @0x00000000035ac670

and exit the parent process, the child continues to run.

I thought detach was meant to be used when we wanted the child process to outlive the parent, and run was expected to behave otherwise.

Is there a portable way to have children as part of a new process group so that all children receive a SIGHUP when the parent exits?

@amitmurthy
Copy link
Contributor Author

I recently had to ensure that a spawned tail -f command exited along with the main julia process. I found one way was to define a finalizer on the process object thus - finalizer(proc, (x)->kill(x)) . If this is reliable and guaranteed to work cross-platform, I'll document the same.

@vtjnash
Copy link
Member

vtjnash commented Mar 25, 2016

afaict, the system only delivers SIGHUP if the child process is sleeping (http://pubs.opengroup.org/onlinepubs/9699919799/functions/_Exit.html). i've confirmed this (so some extent) by sending SIGSTOP or SIGTSTP to the child process and observing that it then does exit in response to the parent dying.

but in general http://stackoverflow.com/a/2035683

amit's finalizer solution also seems reasonable to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This change adds or pertains to documentation
Projects
None yet
Development

No branches or pull requests

3 participants