in reply to Get Entire Command Line of a Program

I have a script that will stay in the background and handle a loop every minute. In the past, I've had trouble with some scripts having memory issues after running like this for too long, so I figured one easy way to handle it would be to grab the command line when first run and save it, then after a few hours, just exec() that same line and die, leaving a new instance running.

It was just an idea of a new way to be lazy (hey, doesn't Larry Wall encourage that?), rather than checking individually for each argument and reconstructing the command line and perhaps trying to reconstruct any IO redirection as well. It's not a "have to" thing, just an idea that it seems clear won't work.

I know I can use a loop in a Perl or bash script to just relaunch every time the program dies, but I figured this might be more self contained.

Since it's not something I can count on, there are other ways to do it. I just thought it might lead to some easy and possibly interesting little tricks of it could work.

Thanks for the help on this!

  • Comment on Re: Get Entire Command Line of a Program

Replies are listed 'Best First'.
Re^2: Get Entire Command Line of a Program
by BrowserUk (Patriarch) on Oct 20, 2010 at 01:48 UTC

    Won't this pretty much do what you're asking for?:

    ... if( some condition ) { ## fork and exit; ## Update: redundant exec $^X, $0, @ARGV; }
      I was hoping to also get anything like IO redirection, but I see from other responses that's not possible. Otherwise, it would do it. Thanks.