-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Jason Holt wrote:
>
> On Sat, 18 Feb 2006, Jason Holt wrote:
>
>>
>> On Sat, 18 Feb 2006, Jason Holt wrote:
>>
>>> I imagine you'll want something involving "echo $$ >myscript.pid" and
>>> then perhaps "ps -a | grep `cat myscript.pid` | grep myscript && kill
>>> `cat myscript.pid` && exit"
>>
>>
>> If you were running a high reliability system, you'd want to do
>> something like the above; otherwise, if the instance of the script
>> that made the pidfile had died, you could end up killing some other
>> process that happened to get that pid the next time around. In some
>> cases you might even have to worry about some other script also being
>> named "myscript" and getting the same pid.
>
>
> Incidentally, there's also a race condition possible with the "check for
> pidfile, run if it's not there" setup -- if two copies of the script ran
> at the same time, they could both end up looking for the pidfile,
> finding it's not there, creating it (one on top of the other) and then
> entering the main loop.
lockfile(1)
lockfile - conditional semaphore-file creator
(comes with procmail)
Although, if you don't need it to be NFS-robust, all you really need to
eliminate the race condition is some program to run:
open(pathname, O_CREAT | O_EXCL)
Frank
- --
Frank Sorenson - KD7TZK
Systems Manager, Computer Science Department
Brigham Young University
[EMAIL PROTECTED]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
iD8DBQFD+XDYaI0dwg4A47wRAht4AKDKCVn9tdZngj2HQfETbB6TQdbQRACgqKGV
gSk8vVoVwjSNfRBb2l0qL60=
=Vnc0
-----END PGP SIGNATURE-----
--------------------
BYU Unix Users Group
http://uug.byu.edu/
The opinions expressed in this message are the responsibility of their
author. They are not endorsed by BYU, the BYU CS Department or BYU-UUG.
___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list