Last active
January 3, 2016 13:29
-
-
Save mix3/8469622 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
echo $$ | |
while : | |
do | |
sleep 1 | |
done |
This file contains hidden or 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 | |
# 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 |
Author
mix3
commented
Jan 17, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment