AIX doesn't have a 'top' command. Well, I'd like to create an emulation for it using perl and "ps guw" piped to sort. I have the following so far:
...
my $pid = fork(); # spawn child
if ( $pid ) { # parent
while ( wait != -1 ) {
while (<>) {
print "Got $_ on STDIN\n";
}
}
} else { # child
while ( 1 ) {
print $header;
print `ps guw | sort -n -r -k $sort_option | head -$num_lines`;
print "\nSort: $sort_option : Lines: $num_lines : Sleep: $sleep_ti
+me\n";
sleep $sleep_time;
print `clear`;
}
}
Pretty rudimentary, but what I would like to do is have the parent process listen for STDIN, like top does, and send a SIGHUP to the child to reset it's sort options, lines or whatnot. The
while (<>) { doesn't seem to be working like I'd hoped. Any ideas on this one?