Sample Header Ad - 728x90

Flocking a filedescriptor in a shell script

5 votes
3 answers
4799 views
I thought this would give me uninterrupted begin-end pairs, but it doesn't: #!/bin/bash fun()( flock 1 || { echo >&2 "$BASHPID: FAIL: $?"; exit 1; } echo "$BASHPID begin" sleep 1; echo "$BASHPID end" ) fun & fun & fun & fun & fun & fun & fun & fun & fun & wait What am I doing wrong?
Asked by Petr Skocik (29590 rep)
Jun 28, 2016, 08:41 PM
Last activity: Apr 7, 2023, 06:00 AM