reyjrar has asked for the wisdom of the Perl Monks concerning the following question:
Because what I noticed during some testing is that getpgrp returns -1 if the pid doesn't exist, a number > 0 if pid exists, and 0 if the pid is 1 (init). Anyone else played with this and have any advice/warnings about doing it this way?#!/usr/bin/perl use strict; my $pid = $ARGV[0] or die "usage: $0 pid\n"; my $group = getpgrp $pid; print "$pid\'s group is $group\n"; if($group >= 0) { print "$pid is active\n"; } else { print "$pid doesn't exist\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Checking PIDs without system calls
by AgentM (Curate) on Mar 06, 2001 at 02:13 UTC | |
by reyjrar (Hermit) on Mar 06, 2001 at 02:30 UTC | |
|
Re: Checking PIDs without system calls
by tadman (Prior) on Mar 06, 2001 at 04:00 UTC |