summaryrefslogtreecommitdiff
path: root/sysutils/psmisc/files/patch-src-pstree.c
diff options
context:
space:
mode:
authorAkinori MUSHA <knu@FreeBSD.org>2010-01-02 16:40:10 +0000
committerAkinori MUSHA <knu@FreeBSD.org>2010-01-02 16:40:10 +0000
commit4b18243f1f45cec47bddffb80a9c26e17213619a (patch)
treea876d7547aa1ddcc501a4ed5b6300d53bb899a96 /sysutils/psmisc/files/patch-src-pstree.c
parentCheck should be <= 900000 (diff)
Update to the latest version 22.9.
Notes
Notes: svn path=/head/; revision=247006
Diffstat (limited to 'sysutils/psmisc/files/patch-src-pstree.c')
-rw-r--r--sysutils/psmisc/files/patch-src-pstree.c159
1 files changed, 50 insertions, 109 deletions
diff --git a/sysutils/psmisc/files/patch-src-pstree.c b/sysutils/psmisc/files/patch-src-pstree.c
index 491e921c5aa2..bcc6128f60e8 100644
--- a/sysutils/psmisc/files/patch-src-pstree.c
+++ b/sysutils/psmisc/files/patch-src-pstree.c
@@ -1,109 +1,50 @@
---- src/pstree.c.orig Fri Nov 25 23:14:48 2005
-+++ src/pstree.c Thu Jan 5 23:34:36 2006
-@@ -590,7 +590,7 @@
- {
- if (!(path = malloc (strlen (PROC_BASE) + strlen (de->d_name) + 10)))
- exit (2);
-- sprintf (path, "%s/%d/stat", PROC_BASE, pid);
-+ sprintf (path, "%s/%d/status", PROC_BASE, pid);
- if ((file = fopen (path, "r")) != NULL)
- {
- empty = 0;
-@@ -608,95 +608,8 @@
- perror (path);
- exit (1);
- }
-- fread(readbuf, BUFSIZ, 1, file) ;
-- if (ferror(file) == 0)
-- {
-- memset(comm, '\0', COMM_LEN+1);
-- tmpptr = strrchr(readbuf, ')'); /* find last ) */
-- /* We now have readbuf with pid and cmd, and tmpptr+2
-- * with the rest */
-- /*printf("readbuf: %s\n", readbuf);*/
-- if (sscanf(readbuf, "%*d (%15[^)]", comm) == 1)
-- {
-- /*printf("tmpptr: %s\n", tmpptr+2);*/
-- if (sscanf(tmpptr+2, "%*c %d", &ppid) == 1)
-- {
--/*
-- if (fscanf
-- (file, "%d (%s) %c %d", &dummy, comm, (char *) &dummy,
-- &ppid) == 4)
-- */
-- {
-- DIR *taskdir;
-- struct dirent *dt;
-- char *taskpath;
-- char *threadname;
-- int thread;
--
-- if (!(taskpath = malloc(strlen(path) + 10))) {
-- exit (2);
-- }
-- sprintf (taskpath, "%s/task", path);
--
-- if ((taskdir=opendir(taskpath))!=0) {
-- /* if we have this dir, we're on 2.6 */
-- if (!(threadname = malloc(strlen(comm) + 3))) {
-- exit (2);
-- }
-- sprintf(threadname,"{%s}",comm);
-- while ((dt = readdir(taskdir)) != NULL) {
-- if ((thread=atoi(dt->d_name)) !=0) {
-- if (thread != pid) {
--#ifdef WITH_SELINUX
-- if (print_args)
-- add_proc(threadname, thread, pid, st.st_uid, threadname, strlen(threadname)+1, scontext);
-- else
-- add_proc(threadname, thread, pid, st.st_uid, NULL, 0, scontext);
--#else /*WITH_SELINUX*/
-- if (print_args)
-- add_proc(threadname, thread, pid, st.st_uid, threadname, strlen(threadname)+1);
-- else
-- add_proc(threadname, thread, pid, st.st_uid, NULL, 0);
--#endif /*WITH_SELINUX*/
-- }
-- }
-- }
-- free(threadname);
-- (void) closedir(taskdir);
-- }
-- free(taskpath);
-- }
--
-- if (!print_args)
--#ifdef WITH_SELINUX
-- add_proc(comm, pid, ppid, st.st_uid, NULL, 0, scontext);
--#else /*WITH_SELINUX*/
-- add_proc (comm, pid, ppid, st.st_uid, NULL, 0);
--#endif /*WITH_SELINUX*/
-- 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;
--#ifdef WITH_SELINUX
-- add_proc(comm, pid, ppid, st.st_uid, buffer, size, scontext);
--#else /*WITH_SELINUX*/
-- add_proc (comm, pid, ppid, st.st_uid, buffer, size);
--#endif /*WITH_SELINUX*/
-- }
-- }
-- }
-+ if (fscanf(file, "%s %*d %d", comm, &ppid) == 2) {
-+ add_proc(comm,pid,ppid,st.st_uid,NULL,0);
- }
- (void) fclose (file);
- }
+--- 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 @@
+ #include <term.h>
+ #include <termios.h>
+ #include <langinfo.h>
++#include <limits.h>
+ #include <assert.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+@@ -590,7 +591,11 @@
+ struct dirent *de;
+ FILE *file;
+ struct stat st;
++#ifdef __FreeBSD__
++ char *path, comm[COMM_LEN + 1];
++#else
+ char *path, *comm;
++#endif
+ char *buffer;
+ size_t buffer_size;
+ char readbuf[BUFSIZ + 1];
+@@ -623,7 +628,7 @@
+ 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);
++ sprintf (path, "%s/%d/status", PROC_BASE, pid);
+ if ((file = fopen(path, "r")) != NULL) {
+ empty = 0;
+ sprintf(path, "%s/%d", PROC_BASE, pid);
+@@ -638,6 +643,10 @@
+ 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);
++#else
+ size = fread(readbuf, 1, BUFSIZ, file);
+ if (ferror(file) == 0) {
+ readbuf[size] = 0;
+@@ -725,6 +734,7 @@
+ }
+ }
+ }
++#endif /*__FreeBSD__*/
+ (void) fclose(file);
+ }
+ free(path);