Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Keep a "system" process running if script is prematurely exited?

by sflitman (Hermit)
on Jun 17, 2010 at 05:44 UTC ( #845145=note: print w/ replies, xml ) Need Help??


in reply to Keep a "system" process running if script is prematurely exited?

Under bash, you can use the disown command to detach it from the process and make it owned by the top-level process init. From bash:

# gedit & # disown $!
Where $! is the last process id. To do this in Perl, I tried this:
# perl -e 'system q{gedit &}'
It starts gedit in its own window on my Ubuntu system and returns to the shell prompt. Then I close the terminal, and voila! gedit is still running. Can anyone tell us why disown is not needed in this case?

HTH,
SSF


Comment on Re: Keep a "system" process running if script is prematurely exited?
Select or Download Code
Re^2: Keep a "system" process running if script is prematurely exited?
by Anonymous Monk on Jun 17, 2010 at 06:32 UTC
    Probably because the perl process that launched gedit is finished (isn't connected to the shell anymore ie STDIN/STDOUT/STDERR are closed)

    You can confirm by comparing strace/truss output with

    perl -e 'system q{gedit &} scalar <>;'
Re^2: Keep a "system" process running if script is prematurely exited?
by cdarke (Prior) on Jun 17, 2010 at 07:54 UTC
    Probably because bash shell option huponexit is set to off (see shopt for option settings).
    By the way, disown -h will supress HUP for a specific job, see help disown

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://845145]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2014-09-15 04:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (145 votes), past polls