2 # Functions for parsing macos server ps output
6 local($pcmd, $line, $i, %pidmap, @plist);
8 open(PS, "ps xlwwwwp $_[0] |");
11 open(PS, "ps axlwwww |");
13 for($i=0; $line=<PS>; $i++) {
15 if ($line =~ /ps axlwwww/ || $line =~ /^\s*UID\s+PID/) { $i--; next; }
16 if ($line =~ /^\s*(\d+)\s+(\d+)\s+(\S+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\S+)\s+(\S+)\s+(\d+)\s+(...)\s+(\S+)\s+(\d+:\d+)\s+(.*)/) {
17 if ($3 <= 0) { $i--; next; }
18 $plist[$i]->{"pid"} = $3;
19 $plist[$i]->{"ppid"} = $4;
20 $plist[$i]->{"size"} = $8;
21 $plist[$i]->{"time"} = $13;
22 $plist[$i]->{"nice"} = $6;
23 $plist[$i]->{"_tty"} = $12 eq '?' ? $text{'edit_none'} : "/dev/tty$12";
24 $plist[$i]->{"args"} = $14;
25 $pidmap{$3} = $plist[$i];
27 elsif ($line =~ /^\s*(\d+)\s+(\d+)\s+(\S+)\s+(\d+)\s+(\d+)\s+(\S+)\s+(\d+)\s+(\d+)\s+(\S+)\s+(...)\s+(\S+)\s+(\d+:\S+)\s+(.*)/) {
28 if ($2 <= 0) { $i--; next; }
29 $plist[$i]->{"pid"} = $2;
30 $plist[$i]->{"ppid"} = $3;
31 $plist[$i]->{"size"} = $7;
32 $plist[$i]->{"time"} = $12;
33 $plist[$i]->{"nice"} = $6;
34 $plist[$i]->{"_tty"} = $11 eq '??' ? $text{'edit_none'} : "/dev/tty$11";
35 $plist[$i]->{"args"} = $13;
36 $pidmap{$2} = $plist[$i];
44 open(PS, "ps auxwwww $_[0] |");
47 $line =~ /^(\S+)\s+(\d+)\s+(\S+)\s+(\S+)/ || next;
49 $pidmap{$2}->{"user"} = $1;
50 $pidmap{$2}->{"cpu"} = "$3 %";
57 # renice_proc(pid, nice)
60 return undef if (&is_readonly_mode());
61 local $out = &backquote_logged("renice $_[1] -p $_[0] 2>&1");
62 if ($?) { return $out; }
66 %info_arg_map=( "_tty", $text{'macos_tty'} );
68 @nice_range = (-20 .. 20);
70 $has_fuser_command = 0;
73 # Returns the filehandles and names for a pty and tty
78 @ptys = map { "/dev/$_" } (grep { /^pty/ } readdir(DEV));
81 foreach $pty (@ptys) {
82 open(PTY, "+>$pty") || next;
85 open(TTY, "+>$tty") || next;
86 local $old = select(PTY); $| = 1;
87 select(TTY); $| = 1; select($old);
88 return (*PTY, *TTY, $pty, $tty);