Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (10)
As of 2019-04-25 16:07 GMT
Find Nodes?
    Voting Booth?
    I am most likely to install a new module from CPAN if:

    Results (127 votes). Check out past polls.

    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!