Created
May 10, 2016 05:43
-
-
Save steveluscher/3916c4f2530a4de8ed391bf967839b2b to your computer and use it in GitHub Desktop.
Learn spam in serial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Exit if *any* error is encountered | |
set -e | |
lockfile="/tmp/.sa-learn-lock" | |
# Make sure the lockfile exists | |
touch $lockfile | |
( | |
# Get the name of the lockfile's descriptor | |
unset descriptior | |
exec {descriptor}< $lockfile | |
# Block until you get an exclusive lock on that descriptor | |
flock -e $descriptor | |
cat | sa-learn "$@" & | |
exit 0 | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment