Eyck has asked for the wisdom of the Perl Monks concerning the following question:
So I was thinking along the lines of:
system("perl -w script.pl"); die();
Howether, that would be problematic if there would be some resource that cannot be shared, and generally it would be better to have the script execute serially, and avoid the parallel execution of the same script.
To do that, I thought about something like that:
or even better:#!/usr/bin/perl sleep(10);
#!/usr/bin/perl BEGIN { sleep(10); };
But it looks unclean and seems like it's not a very good solution.
How would correct solution look like?
update It seems that the correct solution is as suggested by tye:
it seems that besides loading new process image, it cleans up everything I can think of (fds, opened sockets)exec( $^X, $0, @ARGV ) or die "Can't re-exec myself($^X,$0): $!\n";
UPDATE Howether, this doesn't work that well when you pack your scripts with PAR, then what you get is:
Unrecognized character \x7F at /home/eyck/script.exe Line 1
this is of course because script.exe is not a perl script, thus exec($0,@ARGV) should work in that case.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to re-execute self?
by Fletch (Bishop) on Jun 15, 2005 at 18:38 UTC | |
by tye (Sage) on Jun 15, 2005 at 18:54 UTC | |
|
Re: How to re-execute self?
by ikegami (Patriarch) on Jun 15, 2005 at 18:38 UTC |