Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: exec with cleanup

by cyocum (Curate)
on Jun 07, 2004 at 13:43 UTC ( #361976=note: print w/ replies, xml ) Need Help??


in reply to exec with cleanup

A better way to do this would be to use the backtick operator, which returns the return code for the process when it returns or use the system call. That way you know when it ends and then can do some clean up before or after it. I hope this helps.


Comment on Re: exec with cleanup
Re^2: exec with cleanup
by bart (Canon) on Jun 07, 2004 at 13:47 UTC
    But then I'd have to wait until the other script ends, before I can finally end this script. It would effectively keep both in memory at the same time. That doesn't look ideal.
      You can do system("perl script2.pl arg1 arg2 &"), which will return immediately. And system("nohup perl scrip2.pl arg1 arg2 &") won't die when the parent process exits.
Re^2: exec with cleanup
by halley (Prior) on Jun 07, 2004 at 15:12 UTC
    No, backtick does not "return the return code." Backtick (the qx// operator) returns the string of any output that the child process sends to STDOUT. The system() call does return the return code.

    But he wants to abandon everything else in this script, flush all buffers, close all files, release all resources, and at the last possible moment, to jump to the beginning of a new program instead. The exec() function is just a little heavy-handed since it doesn't do all the cleanup first.

    --
    [ e d @ h a l l e y . c c ]

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (12)
As of 2014-08-27 19:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (252 votes), past polls