Re: Unreliable flock

2016-04-05 Thread Corinna Vinschen
On Apr 5 05:08, Andrey Repin wrote: > Greetings, Corinna Vinschen! > > > I guess you read that > > there's a way to use Windows mandatory locks, too. > > Yes, if I compile my own program. But I'm not. I'm writing a shell script. > And /usr/bin/flock fails to lock a file. Even though the man clai

Re: Unreliable flock

2016-04-04 Thread Andrey Repin
Greetings, Corinna Vinschen! > I guess you read that > there's a way to use Windows mandatory locks, too. Yes, if I compile my own program. But I'm not. I'm writing a shell script. And /usr/bin/flock fails to lock a file. Even though the man claims that it "uses an exclusive lock by default". -

Re: Unreliable flock

2016-04-04 Thread Warren Young
On Apr 4, 2016, at 10:51 AM, Andrey Repin wrote: > >> BSD file locks created via flock are only propagated to the direct parent > > that's a showstopper. In short, it makes the function literally useless. Nonsense. That’s only true if “literally” every program that uses BSD locks creates gran

Re: Unreliable flock

2016-04-04 Thread Corinna Vinschen
On Apr 4 19:51, Andrey Repin wrote: > If you mean the part about > > > BSD file locks created via flock are only propagated to the direct parent > > process, not to grand parents or sibling processes. The locks are only valid > > in the creating process, its parent process, and subsequently start

Re: Unreliable flock

2016-04-04 Thread Andrey Repin
Greetings, Corinna Vinschen! >> The script (let's call it test.sh): >> >> #!/bin/dash -x >> _lock="./console-session.lock" >> { >> flock -n 9 || { >> echo "The $(cat "$_lock") command is running already." >> exit 3 >> } >&2 >> >> printf "$1" >&9 >> >> trap 'rm "$_lock";' E

Re: Unreliable flock

2016-04-04 Thread Corinna Vinschen
On Apr 3 00:22, Andrey Repin wrote: > Greetings, All! > > The script (let's call it test.sh): > > #!/bin/dash -x > _lock="./console-session.lock" > { > flock -n 9 || { > echo "The $(cat "$_lock") command is running already." > exit 3 > } >&2 > > printf "$1" >&9 > > trap '

Unreliable flock

2016-04-02 Thread Andrey Repin
Greetings, All! The script (let's call it test.sh): #!/bin/dash -x _lock="./console-session.lock" { flock -n 9 || { echo "The $(cat "$_lock") command is running already." exit 3 } >&2 printf "$1" >&9 trap 'rm "$_lock";' EXIT HUP INT ABRT TERM sleep 20 } 9>> "$_lock" V