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"; }
In reply to Checking PIDs without system calls by reyjrar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |