* clear out some warnings by gcc 9.3.1.
[alpine.git] / web / src / pubcookie / debug.cgi
blobdd9983805c5c5295f28f43e320468f5b70cea7dd
1 #!/usr/bin/perl
2 $| = 1;
3 $wp_uidmapper_bin = "/usr/local/libexec/alpine/bin/wp_uidmapper";
4 $wp_uidmapper_socket = "/tmp/wp_uidmapper";
6 print "Content-type: text/plain\n\n";
7 print "klist:\n";
8 system("/usr/local/bin/klist");
9 print "\n";
11 #if($ENV{'QUERY_STRING'} eq 'stop') {
12 # foreach $line (ps("axww")) {
13 # ($line =~ m/^(\d+).*wp_uidmapper/) && kill(15,$1);
14 # }
15 # sleep(1);
16 # if(-e $wp_uidmapper_socket) {
17 # print "Could not kill wp_uidmapper\n";
18 # exit(1);
19 # }
20 # print "wp_uidmapper stopped\n";
21 # exit 0;
24 if (! -e $wp_uidmapper_socket) {
25 print "Yikes! need to spawn new wp_uidmapper process\n";
26 if(!fork()) {
27 close(STDIN);
28 close(STDOUT);
29 close(STDERR);
30 setpgrp(0,0);
31 exec("$wp_uidmapper_bin 60000-64999");
33 sleep 1;
36 @ps = ps("auxww");
37 print "wp_uidmapper:\n";
38 foreach $line (@ps) { ($line =~ m/wp_uidmapper/) && print $line; }
40 print "\nEnvironment:\n";
41 foreach $key (sort { $a cmp $b } keys(%ENV)) {
42 print "$key: $ENV{$key}\n";
45 print "\nAlpine user processes:\n";
46 foreach $line (@ps) { ($line =~ m/^\#/) && print $line; }
47 exit 0;
49 sub ps {
50 my ($args) = @_;
51 my (@a);
52 open(PS,"ps $args|") || return;
53 @a = <PS>;
54 close(PS);
55 return @a;