Skip to content

Instantly share code, notes, and snippets.

@mix3
Last active January 3, 2016 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mix3/8469622 to your computer and use it in GitHub Desktop.
Save mix3/8469622 to your computer and use it in GitHub Desktop.
#!/bin/bash
echo $$
while :
do
sleep 1
done
#!/bin/bash
# pid指定されなかったり、pid見つからない場合は死ぬ
set -e
PID=$1
kill -0 $PID
shift
set +e
function pid_alive {
RET=`kill -0 $1 2>&1`
if [ "$RET" == "" ]; then
echo 1
else
echo 0
fi
}
while :
do
RET=$(pid_alive $PID)
if [ "$RET" == "0" ]; then
exec $@
break
fi
sleep 1
done
@mix3
Copy link
Author

mix3 commented Jan 17, 2014

$ ./dummy_daemon.sh
97959
^C
$ ./check_and_run.sh 97959 echo "break"
break

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment