summaryrefslogtreecommitdiff
path: root/sysutils/psmisc/files/patch-ac
blob: f172662ebaae8b9eacf74191dc2577fb96229ea4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
--- pstree.c.orig	Tue Aug 26 12:09:05 1997
+++ pstree.c	Sat Dec 19 22:01:20 1998
@@ -9,7 +9,6 @@
 #include <ctype.h>
 #include <unistd.h>
 #include <fcntl.h>
-#include <getopt.h>
 #include <pwd.h>
 #include <dirent.h>
 #include <termios.h>
@@ -17,6 +16,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
+#include <sys/param.h>
 
 #include "comm.h"
 
@@ -387,8 +387,7 @@
     char path[PATH_MAX+1],comm[COMM_LEN+1];
     char *buffer;
     pid_t pid,ppid;
-    int fd,size;
-    int empty,dummy;
+    int empty;
 
     if (!print_args) buffer = NULL;
     else if (!(buffer = malloc((size_t) (output_width+1)))) {
@@ -402,31 +401,15 @@
     empty = 1;
     while (de = readdir(dir))
 	if (pid = atoi(de->d_name)) {
-	    sprintf(path,"%s/%d/stat",PROC_BASE,pid);
+	    sprintf(path,"%s/%d/status",PROC_BASE,pid);
 	    if (file = fopen(path,"r")) {
 		empty = 0;
 		if (fstat(fileno(file),&st) < 0) {
 		    perror(path);
 		    exit(1);
 		}
-		if (fscanf(file,"%d (%[^)]) %c %d",&dummy,comm,(char *) &dummy,
-		  &ppid) == 4) {
-		    if (!print_args) add_proc(comm,pid,ppid,st.st_uid,NULL,0);
-		    else {
-			sprintf(path,"%s/%d/cmdline",PROC_BASE,pid);
-			if ((fd = open(path,O_RDONLY)) < 0) {
-			    perror(path);
-			    exit(1);
-			}
-			if ((size = read(fd,buffer,(size_t) output_width)) < 0)
-			  {
-			    perror(path);
-			    exit(1);
-			}
-			(void) close(fd);
-			if (size) buffer[size++] = 0;
-			add_proc(comm,pid,ppid,st.st_uid,buffer,size);
-		    }
+		if (fscanf(file,"%s %*d %d",comm,&ppid) == 2) {
+		    add_proc(comm,pid,ppid,st.st_uid,NULL,0);
 		}
 		(void) fclose(file);
 	    }
@@ -500,7 +483,7 @@
     while ((c = getopt(argc,argv,"acGhnpluUV")) != EOF)
 	switch (c) {
 	    case 'a':
-		print_args = 1;
+		/* print_args = 1; */
 		break;
 	    case 'c':
 		compact = 0;