diff options
author | Sunpoet Po-Chuan Hsieh <sunpoet@FreeBSD.org> | 2010-10-06 05:58:11 +0000 |
---|---|---|
committer | Sunpoet Po-Chuan Hsieh <sunpoet@FreeBSD.org> | 2010-10-06 05:58:11 +0000 |
commit | 49085cb7dc1e4adefb5bbed514c5f01024c02aec (patch) | |
tree | c83c132ca9447b9e8632d1e5e0e596bb434ce957 /sysutils/psmisc/files/patch-src-pstree.c | |
parent | - set modified date (diff) |
- Add NLS option
- Add LICENSE
- Pass maintainership to submitter
- Update to 22.13 while I'm here
PR: ports/146709
Submitted by: Douglas William Thrift <douglas at douglasthrift.net> (new maintainer)
Approved by: sunpoet (myself, maintainer), pgollucci (mentor)
Notes
Notes:
svn path=/head/; revision=262511
Diffstat (limited to 'sysutils/psmisc/files/patch-src-pstree.c')
-rw-r--r-- | sysutils/psmisc/files/patch-src-pstree.c | 52 |
1 files changed, 38 insertions, 14 deletions
diff --git a/sysutils/psmisc/files/patch-src-pstree.c b/sysutils/psmisc/files/patch-src-pstree.c index 5759cff4a134..c8005758f0a6 100644 --- a/sysutils/psmisc/files/patch-src-pstree.c +++ b/sysutils/psmisc/files/patch-src-pstree.c @@ -1,14 +1,16 @@ --- src/pstree.c.orig 2009-12-27 15:46:47.000000000 +0900 +++ src/pstree.c 2010-01-03 00:52:21.437862505 +0900 -@@ -37,6 +37,7 @@ +@@ -37,6 +37,9 @@ #include <term.h> #include <termios.h> #include <langinfo.h> ++#ifdef __FreeBSD__ +#include <limits.h> ++#endif #include <assert.h> #include <sys/types.h> #include <sys/stat.h> -@@ -590,7 +591,11 @@ +@@ -590,7 +594,11 @@ struct dirent *de; FILE *file; struct stat st; @@ -20,31 +22,53 @@ char *buffer; size_t buffer_size; char readbuf[BUFSIZ + 1]; -@@ -623,7 +628,7 @@ +@@ -623,7 +631,11 @@ if ((pid = (pid_t) atoi(de->d_name)) != 0) { if (! (path = malloc(strlen(PROC_BASE) + strlen(de->d_name) + 10))) exit(2); -- sprintf(path, "%s/%d/stat", PROC_BASE, pid); ++#ifdef __FreeBSD__ + sprintf(path, "%s/%d/status", PROC_BASE, pid); ++#else + sprintf(path, "%s/%d/stat", PROC_BASE, pid); ++#endif if ((file = fopen(path, "r")) != NULL) { empty = 0; sprintf(path, "%s/%d", PROC_BASE, pid); -@@ -638,6 +643,10 @@ +@@ -638,6 +650,29 @@ perror(path); exit(1); } +#ifdef __FreeBSD__ -+ if (fscanf(file, "%s %*d %d", comm, &ppid) == 2) -+ add_proc(comm, pid, ppid, st.st_uid, NULL, 0, 0); ++ /* Read comm and ppid */ ++ if (fscanf(file, "%s %*d %d", readbuf, &ppid) == 2) { ++ tmpptr = readbuf; ++ size = 0; ++ /* Unescape comm */ ++ do { ++ if (*tmpptr == '\\') ++ { ++ char tmp = tmpptr[4]; ++ tmpptr[4] = 0; ++ comm[size++] = strtol(++tmpptr, NULL, 8); ++ tmpptr += 2; ++ tmpptr[1] = tmp; ++ } ++ else ++ comm[size++] = *tmpptr; ++ } while (*++tmpptr); ++ comm[size] = 0; ++ /* Balance braces */ ++ { ++ { +#else size = fread(readbuf, 1, BUFSIZ, file); if (ferror(file) == 0) { readbuf[size] = 0; -@@ -725,6 +734,7 @@ - } - } - } +@@ -692,6 +727,7 @@ + (void) closedir(taskdir); + } + free(taskpath); +#endif /*__FreeBSD__*/ - (void) fclose(file); - } - free(path); + if (!print_args) + #ifdef WITH_SELINUX + add_proc(comm, pid, ppid, st.st_uid, NULL, 0, 0, scontext); |