Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Fellow Perlmonks, I ask for your advise on how to make a script aware of itself (running as another process). What I would like to archive is to make a script die when it knows it is already running in another process. I thought up the following solutions, each having pitfalls though. Solution a) Script 1 gets its own pid and writes it into a file. Script 2 checks for the file and pings the saved pid to see if the process is still running. If the pid is still existing Script 2 will die. (Script 1 will delete the file upon an error-free exit)
Solution b) Do the same as in a) but don't save the PID, just some random piece of data.
Does some perlmonk have a better idea of check for existance of a script in memory that would work across platforms??? thanks /neuroball/ In reply to Make a perl script self aware... by neuroball
|
|