Use "readenv <pid>" to get the full environment block for <pid>.
Use "readenv <pid> [<env> [<env> ...]]" to restrict output to the named
variables.
--- /dev/null
+#!/bin/bash
+
+pid=$1; shift
+
+if [ -z "$pid" ]; then
+ echo >&2 "Usage: readenv <pid> [<env> [<env> ...]]"
+ exit 1
+fi
+
+xargs -n 1 -0 echo < /proc/$pid/environ | (
+ if [ $# -gt 0 ]; then
+ regex=
+ for i in ${1+"$@"}; do regex="$regex|$i"; done
+ regex=${regex#|}
+ regex=${regex%|}
+ [ -n "$regex" ] && regex="^($regex)="
+ exec grep -E "$regex"
+ else
+ exec cat
+ fi
+)