X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=blobdiff_plain;ds=sidebyside;f=bsmtp-pull;h=600763d58e4540b7cd1c6f2ee912aea9fbd3cbd1;hb=a542a487167aada858784adf9f5e1d5884da3d18;hp=2c7e7b9813135bca6a6d73d47e24abd8e891189f;hpb=008357a5011fe968dcdcebc9ce15758651ac0bda;p=bin.git diff --git a/bsmtp-pull b/bsmtp-pull index 2c7e7b9..600763d 100755 --- a/bsmtp-pull +++ b/bsmtp-pull @@ -7,7 +7,7 @@ if [ -z "$1" ]; then exit 1 fi -DIR="$HOME/.bsmtp" +DIR="$HOME/tmp/.bsmtp" mkdir -p "$DIR" cd "$DIR" @@ -19,6 +19,8 @@ HOST="$1" # By default, lockfile-create gives up after three minutes, so don't cron # this any more frequently than that without supplying a --retry argument. lockfile-create "$HOST" +# Race condition pointed out by pjb: this doesn't guarantee that the lock is +# held before the critical section starts. lockfile-touch "$HOST" & TOUCH="$!" trap 'kill "$TOUCH"; lockfile-remove "$HOST"' EXIT ERR HUP INT QUIT TERM