Testing files for existence in /proc
Hello SuSE folkz, I need to test for existence files in /proc: /proc/pid_num/cmdline /proc/pid_num/exe /proc/pid_num/stat The unary file test operators in perl (-r -w -l -z and so on) don't work in this case. I believe 'cause these files are not real. Could somebody please advise me a better way to check these files for existence. Many thanks in advance, Alex.
On Tue, Jan 27, 2004 at 11:25:10AM -0800, Alex Daniloff wrote:
I need to test for existence files in /proc: /proc/pid_num/cmdline /proc/pid_num/exe /proc/pid_num/stat The unary file test operators in perl (-r -w -l -z and so on) don't work in this case. I believe 'cause these files are not real.
Could somebody please advise me a better way to check these files for existence.
If you need to check if some process is still running, you may use this code: $foo=readlink "/proc/$pid/exe" if ( -d "/proc/$pid" ); if defined ($foo) { # process is alive } Regards, -Kastus
participants (2)
-
Alex Daniloff
-
Kastus