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

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Pm-utils mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/pm-utils

Reply via email to