diff options
Diffstat (limited to 'sysutils/psmisc/files/patch-src-pstree.c')
-rw-r--r-- | sysutils/psmisc/files/patch-src-pstree.c | 68 |
1 files changed, 51 insertions, 17 deletions
diff --git a/sysutils/psmisc/files/patch-src-pstree.c b/sysutils/psmisc/files/patch-src-pstree.c index 41e8b79dbcbb..c53d04bff1c2 100644 --- a/sysutils/psmisc/files/patch-src-pstree.c +++ b/sysutils/psmisc/files/patch-src-pstree.c @@ -1,6 +1,6 @@ ---- src/pstree.c.orig Sat Apr 24 14:44:27 2004 -+++ src/pstree.c Sat Sep 10 03:02:07 2005 -@@ -604,7 +604,7 @@ +--- src/pstree.c.orig Tue Oct 11 05:18:48 2005 ++++ src/pstree.c Wed Nov 16 17:31:59 2005 +@@ -590,7 +590,7 @@ { if (!(path = malloc (strlen (PROC_BASE) + strlen (de->d_name) + 10))) exit (2); @@ -9,7 +9,7 @@ if ((file = fopen (path, "r")) != NULL) { empty = 0; -@@ -618,57 +618,9 @@ +@@ -608,90 +608,10 @@ perror (path); exit (1); } @@ -18,11 +18,10 @@ - { - memset(comm, '\0', COMM_LEN+1); - tmpptr = strrchr(readbuf, ')'); /* find last ) */ -- *tmpptr = '\0'; - /* We now have readbuf with pid and cmd, and tmpptr+2 - * with the rest */ - /*printf("readbuf: %s\n", readbuf);*/ -- if (sscanf(readbuf, "%*d (%15c", comm) == 1) +- if (sscanf(readbuf, "%*d (%15[^)]", comm) == 1) - { - /*printf("tmpptr: %s\n", tmpptr+2);*/ - if (sscanf(tmpptr+2, "%*c %d", &ppid) == 1) @@ -32,12 +31,47 @@ - (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 +- add_proc(threadname, thread, pid, st.st_uid, NULL, 0, scontext); +-#else /*WITH_SELINUX*/ +- add_proc(threadname, thread, pid, st.st_uid, NULL, 0); +-#endif /*WITH_SELINUX*/ +- } +- } +- } +- free(threadname); +- (void) closedir(taskdir); +- } +- free(taskpath); +- } +- - if (!print_args) --#ifdef FLASK_LINUX -- add_proc(comm, pid, ppid, st.st_uid, NULL, 0, sid); --#else /*FLASK_LINUX*/ +-#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 /*FLASK_LINUX*/ +-#endif /*WITH_SELINUX*/ - else - { - sprintf (path, "%s/%d/cmdline", PROC_BASE, pid); @@ -54,18 +88,18 @@ - (void) close (fd); - if (size) - buffer[size++] = 0; --#ifdef FLASK_LINUX -- add_proc(comm, pid, ppid, st.st_uid, buffer, size, sid); --#else /*FLASK_LINUX*/ +-#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 /*FLASK_LINUX*/ +-#endif /*WITH_SELINUX*/ - } - } - } + if (fscanf(file, "%s %*d %d", comm, &ppid) == 2) { -+ add_proc(comm,pid,ppid,st.st_uid,NULL,0); ++ add_proc(comm,pid,ppid,st.st_uid,NULL,0); } -- (void) fclose (file); ++ + (void) fclose (file); } free (path); - } |