Commit 0f3ae9fb authored by Julien Muchembled's avatar Julien Muchembled

wrapper script: simplify pid checking

In commit 71d0c4fd, I had in mind to replace
  basename %s
by
  basename "$COMMAND"

Commit cfde18ad was a wrong fix.
parent 8f5fcf65
...@@ -155,16 +155,11 @@ class GenericBaseRecipe(object): ...@@ -155,16 +155,11 @@ class GenericBaseRecipe(object):
lines.append(dedent(""" lines.append(dedent("""
# Check for other instances # Check for other instances
pidfile=%s pidfile=%s
if [ -e $pidfile ]; then if pid=`pgrep -F $pidfile -f "$COMMAND" 2>/dev/null`; then
pid=$(cat $pidfile) echo "Already running with pid $pid."
if [ ! -z "$(ps -p $pid | grep $(basename %s))" ]; then exit 1
echo "Already running with pid $pid."
exit 1
else
rm $pidfile
fi
fi fi
echo $$ > $pidfile""" % (shlex.quote(pidfile), command))) echo $$ > $pidfile""" % shlex.quote(pidfile)))
lines.append(dedent(''' lines.append(dedent('''
# If the wrapped command uses a shebang, execute the referenced # If the wrapped command uses a shebang, execute the referenced
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment