[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Savannah-hackers] Re: emacs/lisp/ChangeLog CVS lock

From: Kim F. Storm
Subject: Re: [Savannah-hackers] Re: emacs/lisp/ChangeLog CVS lock
Date: 13 Jul 2002 01:31:16 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

Mathieu Roy <address@hidden> writes:

> In fact, this is more complex than just removing a lock file. We need
> to remove the process that create the lock file too.

Which is why any sensible application writes its own PID in the
lock files so other applications can easily check whether the
lock is still valid by doing a check like

        while (file_exists(LOCK_FILE)) {
                pid = atoi(read_first_line_of_file(LOCK_FILE));
                if (pid <= 0) {
                        /* lock file is incomplete,
                           wait for locker to write its pid. */
                if (kill(pid, 0) == 0) {
                        /* lock is valid */
                /* remove stale lock and go on */
        /* Now it is our turn to create the file */
Kim F. Storm <address@hidden> http://www.cua.dk

reply via email to

[Prev in Thread] Current Thread [Next in Thread]