Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Simple way to get parent process name?
- X-seq: zsh-users 1802
- From: Ken Lareau <elessar@xxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxxxxxxx
- Subject: Simple way to get parent process name?
- Date: Tue, 15 Sep 1998 14:47:40 -0400
At my current job I compile a lot of various packages, and tend to log
my configuration, compilation and installation procedures for future
reference, using the 'script' command. To keep myself from getting con-
fused as to whether I was in a 'script' process or not, I would have the
shell prompt change to something else while running 'script'.
In ksh, I'd found no easier way to do this other than:
ppid() { /bin/ps -o ppid -p $1 | tail -1; };
pname () { /bin/ps -o comm -p $1 | tail -1; };
for functions to get the PPID and the name, and then testing
$(pname $(ppid $$))
to see if it was equal to 'script'. For Solaris 5.4, the two previous
functions were even worse:
ppid() { /bin/ps -lp $1 | tail -1 | tr -s ' ' | cut -c2- | cut -d' ' -f5; };
pname() { /bin/ps -p $1 | tail -1 | tr -s ' ' | cut -c2- | cut -d' ' -f4; };
So my question is, now that I'm using zsh as my shell at work, is there
a simpler way to do this? I know zsh has PPID, but I need the actual
process name as well.
Any suggestions?
Ken Lareau
elessar@xxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author