Re: Safe unlocking

From: those who know me have no need of my name (not-a-real-address_at_usa.net)
Date: 11/28/03

  • Next message: Jens.Toerring_at_physik.fu-berlin.de: "Re: Safe unlocking"
    Date: 28 Nov 2003 12:13:06 GMT
    
    

    in comp.unix.misc i read:

    >Suppose my program starts with creating and locking the file as the
    >follows:

    >I think that you'll readily agree that calling SIGNAL(2) for each possible
    >signal number would be rather clumsy.

    i don't agree. please do call signal (or better, sigaction) for each
    signal which you need to handle.

    >Therefore my question: what is the sure-fire way to remove lock file
    >come well, come ill?

    one simplistic way to handle normal sorts of unexpected death is to fork
    after creating the lock file, then let the parent remove it when the child
    (which does all the work) exits.

    but there is no sure-fire way, because there are things that can happen
    which can terminate your process which cannot be caught (e.g., SIGKILL or a
    power glitch), so it's probably better for you to plan to validate the lock
    file in some fashion (then `steal' the lock if the validation fails).

    -- 
    a signature
    

  • Next message: Jens.Toerring_at_physik.fu-berlin.de: "Re: Safe unlocking"

    Relevant Pages

    • Re: [PHP] usage of flock
      ... > I am confused with the flock function and its usage. ... > hoping the first job_controller will lock it-self, ... if the server crash down the "surviving" lock file ... locked file from an "exit" or killed script, and then you have to know ...
      (php.general)
    • Re: Cant open websites from Front Page
      ... But they gave me no option to 'delete' the lock file. ... There are reports that FP extensions are not in place for this ... how FP security and NTFS security combine to give the effective rights. ...
      (microsoft.public.frontpage.extensions.windowsnt)
    • Re: [PHP] usage of flock
      ... to use flock. ... hoping the first job_controller will lock it-self, ... I also thought of writing in the lock file the PID of the first ... So how could prevent multiple instance of the same script? ...
      (php.general)
    • Re: FAQ 5.20 Why cant I just open(FH, ">file.lock")?
      ... >> Semaphore locking is a well accepted method, ... instance, means that the lock check AND the lock creation happen in one, ... the while loop exits because the lock file is no longer present ...
      (comp.lang.perl.misc)