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

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.

Replies are listed 'Best First'.
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 arg1 arg2 &"), which will return immediately. And system("nohup perl 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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://361976]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2018-01-22 13:15 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (233 votes). Check out past polls.