Created
July 25, 2019 19:44
-
-
Save ycombinator/e645078f72ad6a180c32af818828a9df to your computer and use it in GitHub Desktop.
Child care
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 | |
CHILD_PIDFILE=$PWD/child.pid | |
# Clean up old child, if any | |
if [ -f $CHILD_PIDFILE ]; then | |
OLD_CHILD_PID=$(cat $CHILD_PIDFILE) | |
ps $OLD_CHILD_PID >/dev/null | |
if [ $? -eq 0 ]; then | |
kill -9 $OLD_CHILD_PID | |
fi | |
rm $CHILD_PIDFILE | |
fi | |
# Spawn child | |
nc -l -p 2000 & | |
CHILD_PID=$! | |
echo $CHILD_PID > $CHILD_PIDFILE | |
# Sleep to give us some time to poke around | |
sleep 30 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment