Guest User

Untitled

a guest
Dec 16th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. #!/bin/bash
  2. pid=$1
  3. me="$(basename $0)($$):"
  4. echo "$me"
  5. if [ -z "$pid" ]
  6. then
  7. echo "$me a PID is required as an argument" >&2
  8. exit 2
  9. fi
  10.  
  11. name=$(ps -p $pid -o comm=)
  12. if [ $? -eq 0 ]
  13. then
  14. echo "$me waiting for PID $pid to finish ($name)"
  15. while ps -p $pid > /dev/null; do sleep 1; done;
  16. else
  17. echo "$me failed to find process with PID $pid" >&2
  18. exit 1
  19. fi
Add Comment
Please, Sign In to add comment