more useful options | |
PerlMonks |
How to re-execute self?by Eyck (Priest) |
on Jun 15, 2005 at 18:35 UTC ( [id://467008]=perlquestion: print w/replies, xml ) | Need Help?? |
Eyck has asked for the wisdom of the Perl Monks concerning the following question:
I would like to clean the state of the script, close all filehandles etc, and I think the best way is to die(), but then, I would need external program to re-execute the script.
So I was thinking along the lines of:
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:
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) Thanks.
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.
Back to
Seekers of Perl Wisdom
|
|