summaryrefslogtreecommitdiff
path: root/sysutils/psmisc/patches/patch-ad
blob: 25e43d3eea4a89e977f5718fffe27b6515c5ec64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
$NetBSD: patch-ad,v 1.7 2013/12/13 09:58:58 jperkin Exp $

Need limits.h for PATH_MAX

--- src/killall.c.orig	2001-03-31 10:26:47.000000000 +0000
+++ src/killall.c
@@ -13,15 +13,16 @@
 #include <dirent.h>
 #include <signal.h>
 #include <errno.h>
+#include <limits.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <getopt.h>
 
 #include "comm.h"
+#include "procfs.h"
 #include "signals.h"
 
 
-#define PROC_BASE "/proc"
 #define MAX_NAMES (sizeof(unsigned long)*8)
 
 
@@ -138,11 +139,15 @@ kill_all (int signal, int names, char **
     }
   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
       okay = fscanf (file, "%*d (%[^)]", comm) == 1;
+#endif
       (void) fclose (file);
       if (!okay)
 	continue;
@@ -151,7 +156,10 @@ kill_all (int signal, int names, char **
       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
+	  sprintf (path, "%s/%d/%s", PROC_BASE, pid_table[i], CMDLINE_FILE);
 	  if (!(file = fopen (path, "r")))
 	    continue;
           while (1) {
@@ -180,6 +188,7 @@ kill_all (int signal, int names, char **
             }
           }
           (void) fclose(file);
+#endif
 	  if (exact && !okay)
 	    {
 	      if (verbose)
@@ -206,7 +215,7 @@ kill_all (int signal, int names, char **
 	    }
 	  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 +378,7 @@ main (int argc, char **argv)
   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;