1use warnings; 2use Test::More; 3use Data::Dumper; 4 5BEGIN { 6 use_ok('Proc::ProcessTable'); 7} 8 9SKIP: { 10 $0 = "PROC_PROCESSTABLE_TEST_CMD"; 11 sleep(1); 12 13 my ($ps) = grep {/^$$\s+/} map { chomp; s/^\s*//; $_ } `ps xww`; 14 skip 'Cannot set process name', 1 15 unless ($ps && $ps =~ /PROC_PROCESSTABLE_TEST_CMD/); 16 17 $SIG{CHLD} = 'IGNORE'; 18 19 my $pid = fork; 20 die "cannot fork" unless defined $pid; 21 22 if ($pid == 0) { 23 #child 24 $0 = '01234567890123456789'; 25 sleep 10000; 26 } else { 27 #main 28 sleep 1; 29 my $t = Proc::ProcessTable->new; 30 my ($p) = grep { $_->{pid} == $pid } @{ $t->table }; 31 like($p->{cmndline}, qr/01234567890123456789/, "modulo 20 commandline bugfix"); 32 kill 9, $pid; 33 } 34} 35done_testing(); 36 37