Fixup fromcvs/togit conversion
[minix-pkgsrc.git] / sysutils / psmisc / patches / patch-ad
blob4fc9175cc41c1432fa3335f85b92a57db18f9b4b
1 $NetBSD$
3 --- src/killall.c.orig  Sat Mar 31 05:26:47 2001
4 +++ src/killall.c
5 @@ -18,10 +18,10 @@
6  #include <getopt.h>
7  
8  #include "comm.h"
9 +#include "procfs.h"
10  #include "signals.h"
13 -#define PROC_BASE "/proc"
14  #define MAX_NAMES (sizeof(unsigned long)*8)
17 @@ -138,11 +138,15 @@
18      }
19    for (i = 0; i < pids; i++)
20      {
21 -      sprintf (path, PROC_BASE "/%d/stat", pid_table[i]);
22 +      sprintf (path, "%s/%d/%s", PROC_BASE, pid_table[i], STATUS_FILE);
23        if (!(file = fopen (path, "r")))
24         continue;
25        empty = 0;
26 +#ifdef BSD_44_PROCFS
27 +      okay = fscanf (file, "%s", comm) == 1;
28 +#else
29        okay = fscanf (file, "%*d (%[^)]", comm) == 1;
30 +#endif
31        (void) fclose (file);
32        if (!okay)
33         continue;
34 @@ -151,7 +155,10 @@
35        length = strlen (comm);
36        if (length == COMM_LEN - 1)
37         {
38 -         sprintf (path, PROC_BASE "/%d/cmdline", pid_table[i]);
39 +#if defined(BSD_44_PROCFS) && !defined(BSD_PROCFS_CMDLINE)
40 +         okay = 0;
41 +#else
42 +         sprintf (path, "%s/%d/%s", PROC_BASE, pid_table[i], CMDLINE_FILE);
43           if (!(file = fopen (path, "r")))
44             continue;
45            while (1) {
46 @@ -180,6 +187,7 @@
47              }
48            }
49            (void) fclose(file);
50 +#endif
51           if (exact && !okay)
52             {
53               if (verbose)
54 @@ -206,7 +214,7 @@
55             }
56           else
57             {
58 -             sprintf (path, PROC_BASE "/%d/exe", pid_table[i]);
59 +             sprintf (path, "%s/%d/%s", PROC_BASE, pid_table[i], EXE_FILE);
60               if (stat (path, &st) < 0)
61                 continue;
62               if (sts[j].st_dev != st.st_dev || sts[j].st_ino != st.st_ino)
63 @@ -369,7 +377,7 @@
64    sig_num = SIGTERM;
66    opterr = 0;
67 -  while ( (optc = getopt_long_only(argc,argv,"egilqs:vwV",options,NULL)) != EOF) {
68 +  while ( (optc = getopt_long(argc,argv,"egilqs:vwV",options,NULL)) != EOF) {
69      switch (optc) {
70        case 'e':
71          exact = 1;