[buug] checking a pid
Ian Zimmerman
itz at speakeasy.org
Wed Feb 26 20:55:42 PST 2003
itz> Under Linux, I solved this by stat'ing /proc/<pid>/ . What is
itz> the BSD way?
jan> ps -axjw | grep foo | awk '{print $3}'
jan> the "j" flag is handy.
Well, I need this in a C program, not as something I type into the
shell. Setting up that full pipeline wouldn't be completely trivial.
But yes, after firing off my question I thought about just forking
a ps process and checking its exit status. Fortunately I only need to
do this once; if it was in a loop, this solution wouldn't satisfy.
--
Ian Zimmerman, Oakland, California, U.S.A.
if (sizeof(signed) > sizeof(unsigned) + 4) { delete this; }
GPG: 433BA087 9C0F 194F 203A 63F7 B1B8 6E5A 8CA3 27DB 433B A087
More information about the buug
mailing list