Created
February 5, 2016 21:15
-
-
Save richlowe/20d40628e50162af9079 to your computer and use it in GitHub Desktop.
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 | |
eflag= | |
while getopts e opt; do | |
case $opt in | |
e) eflag=1;; | |
\?) printf "Usage: pargs [-e] <pid> ...]"; exit 2;; | |
esac | |
done | |
shift $(($OPTIND - 1)) | |
cmdline() { | |
tr '\0' ' ' < /proc/$1/cmdline | |
} | |
environ() { | |
# XXX: Sadly, mawk doesn't accept \0 as RS, and treats it as RS="" | |
gawk 'BEGIN { RS="\0"; } { printf "envp[%d]: ", NR - 1; print }' < /proc/$1/environ | |
} | |
while (($# > 0)); do | |
echo $1: $(cmdline $1) | |
[[ -n $eflag ]] && environ $1 | |
shift | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment