Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!mcvax!hp4nl!ctisbv!pim From: pim@ctisbv.UUCP (Pim Zandbergen) Newsgroups: comp.unix.questions Subject: Re: Summary - How to tell if a process is active Keywords: process kill ps Message-ID: <763@ctisbv.UUCP> Date: 20 Jun 89 22:00:43 GMT References: <2848@infocenter.UUCP> Reply-To: pim@ctisbv.UUCP (Pim Zandbergen) Organization: CTI Software BV, The Hague, The Netherlands Lines: 39 In article <2848@infocenter.UUCP> mhoffman@infocenter.UUCP (Mike Hoffman) writes: > > >Thanks to all who answered my request for a better approach. The >correct way to tell if a process is active is by using kill(2), >and sending a signal of 0. This will perform error checking, but >does not actually send a signal to the process. > I have a question that is related this one. Our applications use the same style of lock-files as are used in uucp: when a resource is claimed, a lockfile is created with a name that reflects the claimed resource and a content that holds the pid of the resource claiming process, so other processes can check the validity of the claim by examing if the process still is alive. But as our application is mainly turnkey based, I have seen more then once that checking the pid only is not enough. Our customers turn on the machine, and go right away into the application. At that time a resource is being claimed. Then there is a system crash, the system is rebooted, and the application is restarteds, AND IS RUNNING WITH THE EXACT SAME PID! Hence, when it finds the lockfile, it checks for its pid and finds out it exists, and fails to claim the resource. The second time the application is started it will continue without failure. So I am looking for some way to put some extra information into the lockfile to find out if the machine has been rebooted since the resource claim. What is the most obvious and portable way to do this? Thanks for any responses. Pim. -- --------------------+----------------------+----------------------------------- Pim Zandbergen | phone: +31 70 542302 | CTI Software BV pim@ctisbv.UUCP | fax : +31 70 512837 | Laan Copes van Cattenburch 70 ...!uunet!mcvax!hp4nl!ctisbv!pim | 2585 GD The Hague, The Netherlands