ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/pack/freebsd/sysutils/psmisc/files/patch-src-pstree.c
(Generate patch)

Comparing freebsd/sysutils/psmisc/files/patch-src-pstree.c (file contents):
Revision 279 by douglas, 2010-05-18T03:59:26-07:00 vs.
Revision 339 by douglas, 2010-08-12T00:04:19-07:00

# Line 1 | Line 1
1   --- src/pstree.c.orig   2009-12-27 15:46:47.000000000 +0900
2   +++ src/pstree.c        2010-01-03 00:52:21.437862505 +0900
3 < @@ -37,6 +37,7 @@
3 > @@ -37,6 +37,9 @@
4   #include <term.h>
5   #include <termios.h>
6   #include <langinfo.h>
7 + +#ifdef __FreeBSD__
8   +#include <limits.h>
9 + +#endif
10   #include <assert.h>
11   #include <sys/types.h>
12   #include <sys/stat.h>
13 < @@ -590,7 +591,11 @@
13 > @@ -590,7 +594,11 @@
14     struct dirent *de;
15     FILE *file;
16     struct stat st;
# Line 20 | Line 22
22     char *buffer;
23     size_t buffer_size;
24     char readbuf[BUFSIZ + 1];
25 < @@ -623,7 +628,7 @@
25 > @@ -623,7 +631,11 @@
26       if ((pid = (pid_t) atoi(de->d_name)) != 0) {
27         if (! (path = malloc(strlen(PROC_BASE) + strlen(de->d_name) + 10)))
28           exit(2);
29 < -      sprintf(path, "%s/%d/stat", PROC_BASE, pid);
30 < +      sprintf (path, "%s/%d/status", PROC_BASE, pid);
29 > +#ifdef __FreeBSD__
30 > +      sprintf(path, "%s/%d/status", PROC_BASE, pid);
31 > +#else
32 >       sprintf(path, "%s/%d/stat", PROC_BASE, pid);
33 > +#endif
34         if ((file = fopen(path, "r")) != NULL) {
35           empty = 0;
36           sprintf(path, "%s/%d", PROC_BASE, pid);
37 < @@ -638,6 +643,10 @@
37 > @@ -638,6 +650,29 @@
38             perror(path);
39             exit(1);
40           }
41   +#ifdef __FreeBSD__
42 < +        if (fscanf(file, "%s %*d %d", comm, &ppid) == 2)
43 < +          add_proc(comm, pid, ppid, st.st_uid, NULL, 0, 0);
42 > +        /* Read comm and ppid */
43 > +        if (fscanf(file, "%s %*d %d", readbuf, &ppid) == 2) {
44 > +          tmpptr = readbuf;
45 > +          size = 0;
46 > +          /* Unescape comm */
47 > +          do {
48 > +            if (*tmpptr == '\\')
49 > +            {
50 > +              char tmp = tmpptr[4];
51 > +              tmpptr[4] = 0;
52 > +              comm[size++] = strtol(++tmpptr, NULL, 8);
53 > +              tmpptr += 2;
54 > +              tmpptr[1] = tmp;
55 > +            }
56 > +            else
57 > +              comm[size++] = *tmpptr;
58 > +          } while (*++tmpptr);
59 > +          comm[size] = 0;
60 > +          /* Balance braces */
61 > +          {
62 > +            {
63   +#else
64           size = fread(readbuf, 1, BUFSIZ, file);
65           if (ferror(file) == 0) {
66             readbuf[size] = 0;
67 < @@ -725,6 +734,7 @@
68 <             }
69 <           }
70 <         }
67 > @@ -692,6 +727,7 @@
68 >                   (void) closedir(taskdir);
69 >                 }
70 >               free(taskpath);
71   +#endif /*__FreeBSD__*/
72 <         (void) fclose(file);
73 <       }
74 <       free(path);
72 >               if (!print_args)
73 > #ifdef WITH_SELINUX
74 >                 add_proc(comm, pid, ppid, st.st_uid, NULL, 0, 0, scontext);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines