Skip to content

Instantly share code, notes, and snippets.

@cslarsen
Created June 8, 2016 07:42
Show Gist options
  • Save cslarsen/f7a92694ed445e9e881c9fed73b87cdc to your computer and use it in GitHub Desktop.
Save cslarsen/f7a92694ed445e9e881c9fed73b87cdc to your computer and use it in GitHub Desktop.

Revisions

  1. cslarsen created this gist Jun 8, 2016.
    14 changes: 14 additions & 0 deletions pwait.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    #!/bin/bash

    if [ $# -eq 0 ]; then
    echo "Usage: pwait <PID>"
    echo "Waits until PID has terminated, then continues."
    echo "Example: pwait 123 && echo DONE"
    exit 1
    fi

    for pid in "$@"; do
    while [ -e /proc/$pid ]; do
    sleep 0.1
    done
    done