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 280 by douglas, 2010-05-18T08:39:43-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 @@
1 > --- src/pstree.c.orig   2010-04-08 05:20:10.000000000 -0700
2 > +++ src/pstree.c        2010-05-18 07:20:57.583839746 -0700
3 > @@ -37,6 +37,10 @@
4   #include <term.h>
5   #include <termios.h>
6   #include <langinfo.h>
7 + +#ifdef __FreeBSD__
8 + +#include <locale.h>
9   +#include <limits.h>
10 + +#endif
11   #include <assert.h>
12   #include <sys/types.h>
13   #include <sys/stat.h>
14 < @@ -590,7 +591,11 @@
14 > @@ -590,7 +594,11 @@
15     struct dirent *de;
16     FILE *file;
17     struct stat st;
# Line 20 | Line 23
23     char *buffer;
24     size_t buffer_size;
25     char readbuf[BUFSIZ + 1];
26 < @@ -623,7 +628,7 @@
26 > @@ -623,7 +631,11 @@
27       if ((pid = (pid_t) atoi(de->d_name)) != 0) {
28         if (! (path = malloc(strlen(PROC_BASE) + strlen(de->d_name) + 10)))
29           exit(2);
30 < -      sprintf(path, "%s/%d/stat", PROC_BASE, pid);
31 < +      sprintf (path, "%s/%d/status", PROC_BASE, pid);
30 > +#ifdef __FreeBSD__
31 > +      sprintf(path, "%s/%d/status", PROC_BASE, pid);
32 > +#else
33 >       sprintf(path, "%s/%d/stat", PROC_BASE, pid);
34 > +#endif
35         if ((file = fopen(path, "r")) != NULL) {
36           empty = 0;
37           sprintf(path, "%s/%d", PROC_BASE, pid);
38 < @@ -638,6 +643,10 @@
38 > @@ -638,6 +650,29 @@
39             perror(path);
40             exit(1);
41           }
42   +#ifdef __FreeBSD__
43 < +        if (fscanf(file, "%s %*d %d", comm, &ppid) == 2)
44 < +          add_proc(comm, pid, ppid, st.st_uid, NULL, 0, 0);
43 > +        /* Read comm and ppid */
44 > +        if (fscanf(file, "%s %*d %d", readbuf, &ppid) == 2) {
45 > +          tmpptr = readbuf;
46 > +          size = 0;
47 > +          /* Unescape comm */
48 > +          do {
49 > +            if (*tmpptr == '\\')
50 > +            {
51 > +              char tmp = tmpptr[4];
52 > +              tmpptr[4] = 0;
53 > +              comm[size++] = strtol(++tmpptr, NULL, 8);
54 > +              tmpptr += 2;
55 > +              tmpptr[1] = tmp;
56 > +            }
57 > +            else
58 > +              comm[size++] = *tmpptr;
59 > +          } while (*++tmpptr);
60 > +          comm[size] = 0;
61 > +          /* Balance braces */
62 > +          {
63 > +            {
64   +#else
65           size = fread(readbuf, 1, BUFSIZ, file);
66           if (ferror(file) == 0) {
67             readbuf[size] = 0;
68 < @@ -725,6 +734,7 @@
69 <             }
70 <           }
71 <         }
68 > @@ -692,6 +727,7 @@
69 >                   (void) closedir(taskdir);
70 >                 }
71 >               free(taskpath);
72   +#endif /*__FreeBSD__*/
73 <         (void) fclose(file);
74 <       }
75 <       free(path);
73 >               if (!print_args)
74 > #ifdef WITH_SELINUX
75 >                 add_proc(comm, pid, ppid, st.st_uid, NULL, 0, 0, scontext);
76 > @@ -860,6 +896,10 @@
77 >      * command-line options, if given.
78 >      */
79 >
80 > +#ifdef __FreeBSD__
81 > +    /* Actually set the locale because nl_langinfo won't do it. */
82 > +    setlocale(LC_CTYPE, "");
83 > +#endif
84 >     if (isatty(1) && !strcmp(nl_langinfo(CODESET), "UTF-8")) {
85 >         /* Use UTF-8 symbols if the locale's character set is UTF-8. */
86 >         sym = &sym_utf;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines