BSD-Process
view release on metacpan or search on metacpan
}
return(kip);
}
void store_uid (HV *h, const char *field, uid_t uid) {
struct passwd *pw;
size_t flen;
size_t len;
flen = strlen(field);
if (!(pw = getpwuid(uid))) {
/* shouldn't ever happen... */
hv_store(h, field, flen, newSViv(uid), 0);
}
else {
len = strlen(pw->pw_name);
hv_store(h, field, flen, newSVpvn(pw->pw_name,len), 0);
}
}
void store_gid (HV *h, const char *field, gid_t gid) {
t/01-func.t view on Meta::CPAN
my $parent = BSD::Process::info($info->{ppid});
is( $parent->{pid}, $info->{ppid}, 'my parent is indeed my parent' );
isnt( $info->{pid}, $parent->{ppid}, 'I am not my grandparent' );
isnt( $parent->{pid}, $parent->{ppid}, 'and my parent is not my grandparent' );
SKIP: {
skip( "not supported on FreeBSD 4.x", 6 )
if $RUNNING_ON_FREEBSD_4;
my $resolved = BSD::Process::info({resolve => 1});
is( $resolved->{uid}, scalar(getpwuid($info->{uid})), 'resolve implicit pid' );
$resolved = BSD::Process::info($info->{pid}, {resolve => 1});
is( $resolved->{uid}, scalar(getpwuid($info->{uid})), 'resolve explicit pid' );
my $root = BSD::Process::all( uid => 'root' );
my $uid_root_count = 0;
$root->{$_}->uid == 0 and ++$uid_root_count for keys %$root;
is( $uid_root_count, scalar(keys %$root), q{counted all uid root's processes} );
$root = BSD::Process::all( effective_user_id => 'root' );
$uid_root_count = 0;
$root->{$_}->uid == 0 and ++$uid_root_count for keys %$root;
is( $uid_root_count, scalar(keys %$root), q{counted all effective uid root's processes} );
( run in 0.326 second using v1.01-cache-2.11-cpan-8d75d55dd25 )