Handle hostnames with upper-case letters
[webmin.git] / proc / tail.cgi
1 #!/usr/local/bin/perl
2
3 require './proc-lib.pl';
4 &ReadParse();
5 if ($in{'id'}) {
6         $idfile = "$module_config_directory/$in{'id'}.tail";
7         open(IDFILE, ">$idfile");
8         print IDFILE $$,"\n";
9         close(IDFILE);
10         $SIG{'HUP'} = \&hup_handler;
11         }
12 $| = 1;
13 print "Content-type: text/plain\n\n";
14 $trace = &open_process_trace($in{'pid'},
15                              $in{'syscalls'} ? [ split(/\s+/, $in{'syscalls'}) ]
16                                              : undef);
17 while($action = &read_process_trace($trace)) {
18         local $tm = strftime("%H:%M:%S", localtime($action->{'time'}));
19         print join("\t", $tm, $action->{'call'},
20                          join(", ", @{$action->{'args'}}),
21                          $action->{'rv'}),"\n";
22         }
23 &close_process_trace($trace);
24 unlink($idfile) if ($idfile);
25
26 sub hup_handler
27 {
28 &close_process_trace($trace);
29 unlink($idfile);
30 exit;
31 }
32