Created
February 5, 2013 10:16
-
-
Save ormaaj/4713524 to your computer and use it in GitHub Desktop.
BASHPID
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
if [[ ${!KSH_VERSION} == .sh.version ]]; then | |
if builtin pids 2>/dev/null; then | |
function BASHPID.get { .sh.value=$(pids -f '%(pid)d'); } | |
elif [[ -r /proc/self/stat ]]; then | |
function BASHPID.get { read -r .sh.value _ </proc/self/stat; } | |
else | |
function BASHPID.get { .sh.value=$(exec sh -c 'echo $PPID'); } | |
fi | |
elif [[ ! ${BASHPID+_} ]]; then | |
echo 'BASHPID requires Bash, ksh93, or mksh >= R41' >&2 | |
exit 1 | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment