Or move the lock directory to a location that is (or should be auto-cleaned), like /tmp, or just clean it ourselves with a boot-time init script.
Using PID values seems like a waste of time if you are using them to detect stale lockfiles over reboots -- the presence or absence of a given PID is meaningless in that case. If there is a case in which suspend/resume fails, the system does not reboot (or hang and get rebooted), and the lock directory does not get removed, then that is a fault in the pm-utils scripting that needs fixed (imao). On Jan 4, 2008 3:40 PM, Till Maas <[EMAIL PROTECTED]> wrote: > > On Fr Januar 4 2008, Victor Lowther wrote: > > While browsing through the source of pm-utils, I noticed that the > > lock/unlocking functions were using file creation/removal and PID > > checking for locking purposes. In a shell scripting language, > > however, there is no way to atomically create files. > > > > Directory creation, however, is atomic. Here is a patch to atomicize > > the lock/unlick functions. > > You are so cool, there is a bug about this in Red Hat Bugzilla for Fedora and > I did not know how to fix it. You seem to be the man. But there is one > problem with your patch left, though. Now a stale lock directory is not > removed, e.g. when it was left because a suspend failed and one needed to > reset the computer. Do you know the best solution for this, too? > > I guess adding a second lock directory may help here: > > mkdir /.suspended > - on success: continue, store PID in /.suspended/pid > - on failure: > mkdir /.suspended/cleanup > - on failure: quit > - on sucess: check pid in /.suspended/pid > - process still running: remove /.suspended/cleanup and quit > - else: store own pid in /.suspended/pid > remove /.suspended/cleanup > continue > > Regards, > Till > > _______________________________________________ > Pm-utils mailing list > [email protected] > http://lists.freedesktop.org/mailman/listinfo/pm-utils > > _______________________________________________ Pm-utils mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/pm-utils
