Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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
Replies are listed 'Best First'.
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
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 <>;'

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 studying the Monastery: (13)
As of 2015-07-31 12:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (277 votes), past polls