diff options
Diffstat (limited to 'sysutils/psmisc/patches/patch-ad')
-rw-r--r-- | sysutils/psmisc/patches/patch-ad | 164 |
1 files changed, 58 insertions, 106 deletions
diff --git a/sysutils/psmisc/patches/patch-ad b/sysutils/psmisc/patches/patch-ad index 78ac3f89b45..2e68a586851 100644 --- a/sysutils/psmisc/patches/patch-ad +++ b/sysutils/psmisc/patches/patch-ad @@ -1,119 +1,71 @@ -$NetBSD: patch-ad,v 1.5 2001/01/11 18:47:18 jlam Exp $ +$NetBSD: patch-ad,v 1.6 2001/04/24 16:59:35 jlam Exp $ ---- pstree.c.orig Sat May 1 15:40:56 1999 -+++ pstree.c Thu Jan 11 13:38:53 2001 -@@ -2,6 +2,9 @@ - - /* Copyright 1993-1999 Werner Almesberger. See file COPYING for details. */ - -+#ifdef linux -+#define HAVE_GETOPT_H -+#endif - - #include <stdlib.h> - #include <stdio.h> -@@ -9,17 +12,26 @@ - #include <ctype.h> - #include <unistd.h> - #include <fcntl.h> -+#ifdef HAVE_GETOPT_H +--- src/killall.c.orig Sat Mar 31 05:26:47 2001 ++++ src/killall.c +@@ -18,10 +18,10 @@ #include <getopt.h> -+#endif - #include <pwd.h> - #include <dirent.h> - #include <termios.h> - #include <termcap.h> -+#include <sys/param.h> - #include <sys/types.h> - #include <sys/stat.h> - #include <sys/ioctl.h> #include "comm.h" ++#include "procfs.h" + #include "signals.h" -+#if (defined(BSD) && BSD >= 199306) -+#define BSD_44_PROC -+#if (defined(__NetBSD_Version__) && __NetBSD_Version__ >= 104180000) -+#define BSD_PROC_CMDLINE -+#endif -+#endif - #ifndef MAX_DEPTH - #define MAX_DEPTH 100 -@@ -252,6 +264,7 @@ - const struct passwd *pw; - int lvl,i,add,offset,len,swapped,info,count,comm_len,first; - const char *tmp,*here; -+ char tbuf[1024], *pbuf; - char comm_tmp[5]; +-#define PROC_BASE "/proc" + #define MAX_NAMES (sizeof(unsigned long)*8) - if (!current) return; -@@ -270,7 +283,8 @@ - add = out_int(rep)+2; - out_string("*["); - } -- if (current->highlight && (tmp = tgetstr("md",NULL))) tputs(tmp,1,putchar); -+ pbuf = tbuf; -+ if (current->highlight && (tmp = tgetstr("md",&pbuf))) tputs(tmp,1,putchar); - if (swapped = print_args && current->argc < 0) out_char('('); - comm_len = 0; - for (here = current->comm; *here; here++) -@@ -297,7 +311,8 @@ - else (void) out_int(current->uid); - } - if (info || swapped) out_char(')'); -- if (current->highlight && (tmp = tgetstr("me",NULL))) tputs(tmp,1,putchar); -+ pbuf = tbuf; -+ if (current->highlight && (tmp = tgetstr("me",&pbuf))) tputs(tmp,1,putchar); - if (print_args) { - for (i = 0; i < current->argc; i++) { - out_char(' '); -@@ -387,8 +402,13 @@ - char path[PATH_MAX+1],comm[COMM_LEN+1]; - char *buffer; - pid_t pid,ppid; -+#if !defined(BSD_44_PROC) || defined(BSD_PROC_CMDLINE) - int fd,size; -- int empty,dummy; -+#endif -+#if !defined(BSD_44_PROC) -+ int dummy; -+#endif -+ int empty; - if (!print_args) buffer = NULL; - else if (!(buffer = malloc((size_t) (output_width+1)))) { -@@ -402,15 +422,26 @@ - empty = 1; - while (de = readdir(dir)) - if (pid = atoi(de->d_name)) { -+#ifdef BSD_44_PROC -+ sprintf(path,"%s/%d/status",PROC_BASE,pid); -+#else - sprintf(path,"%s/%d/stat",PROC_BASE,pid); -+#endif - if (file = fopen(path,"r")) { - empty = 0; - if (fstat(fileno(file),&st) < 0) { - perror(path); - exit(1); - } -+#ifdef BSD_44_PROC -+ if (fscanf(file,"%s %*d %d",comm,&ppid) == 2) { +@@ -138,11 +138,15 @@ + } + for (i = 0; i < pids; i++) + { +- sprintf (path, PROC_BASE "/%d/stat", pid_table[i]); ++ sprintf (path, "%s/%d/%s", PROC_BASE, pid_table[i], STATUS_FILE); + if (!(file = fopen (path, "r"))) + continue; + empty = 0; ++#ifdef BSD_44_PROCFS ++ okay = fscanf (file, "%s", comm) == 1; +#else - if (fscanf(file,"%d (%[^)]) %c %d",&dummy,comm,(char *) &dummy, - &ppid) == 4) { + okay = fscanf (file, "%*d (%[^)]", comm) == 1; +#endif -+#if defined(BSD_44_PROC) && !defined(BSD_PROC_CMDLINE) -+ add_proc(comm,pid,ppid,st.st_uid,NULL,0); + (void) fclose (file); + if (!okay) + continue; +@@ -151,7 +155,10 @@ + length = strlen (comm); + if (length == COMM_LEN - 1) + { +- sprintf (path, PROC_BASE "/%d/cmdline", pid_table[i]); ++#if defined(BSD_44_PROCFS) && !defined(BSD_PROCFS_CMDLINE) ++ okay = 0; +#else - if (!print_args) add_proc(comm,pid,ppid,st.st_uid,NULL,0); - else { - sprintf(path,"%s/%d/cmdline",PROC_BASE,pid); -@@ -427,6 +458,7 @@ - if (size) buffer[size++] = 0; - add_proc(comm,pid,ppid,st.st_uid,buffer,size); - } ++ sprintf (path, "%s/%d/%s", PROC_BASE, pid_table[i], CMDLINE_FILE); + if (!(file = fopen (path, "r"))) + continue; + while (1) { +@@ -180,6 +187,7 @@ + } + } + (void) fclose(file); +#endif - } - (void) fclose(file); + if (exact && !okay) + { + if (verbose) +@@ -206,7 +214,7 @@ } + else + { +- sprintf (path, PROC_BASE "/%d/exe", pid_table[i]); ++ sprintf (path, "%s/%d/%s", PROC_BASE, pid_table[i], EXE_FILE); + if (stat (path, &st) < 0) + continue; + if (sts[j].st_dev != st.st_dev || sts[j].st_ino != st.st_ino) +@@ -369,7 +377,7 @@ + sig_num = SIGTERM; + + opterr = 0; +- while ( (optc = getopt_long_only(argc,argv,"egilqs:vwV",options,NULL)) != EOF) { ++ while ( (optc = getopt_long(argc,argv,"egilqs:vwV",options,NULL)) != EOF) { + switch (optc) { + case 'e': + exact = 1; |