GNU bug report logs - #56631
flock does not unlock instantly

Previous Next

Package: coreutils;

Reported by: Alexey Kuznetsov <kuznetsov.alexey <at> gmail.com>

Date: Mon, 18 Jul 2022 15:51:01 UTC

Severity: normal

Tags: notabug

Done: Bernhard Voelker <mail <at> bernhard-voelker.de>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Alexey Kuznetsov <kuznetsov.alexey <at> gmail.com>
To: 56631 <at> debbugs.gnu.org
Subject: bug#56631: flock does not unlock instantly
Date: Mon, 18 Jul 2022 13:50:09 +0300
[Message part 1 (text/plain, inline)]
Simple bash script:

#!/bin/bashset -eexec 7<"$0"flock -n 7sleep 60

Will prevent a second instance from being executed (exits instantly). But
if the first instance got killed by 'killall test.sh', the second instance
of the script can be executed only after 60 seconds. First instance of the
script does report being killed instantly, but still does not let me run
the second instance of the script. That makes me think, sleep command not
being killed / handled correctly. Here is a work around example, using the
following script makes it work correctly:

#!/bin/bashset -etrap "kill 0" SIGINT SIGTERMexec 7<"$0"flock -n 7sleep 60


Flock waits until sleep finishes, even when the script holding lock is
killed. Is it a bug or feature?


-- AK
[Message part 2 (text/html, inline)]

This bug report was last modified 2 years and 303 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.