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
|
$NetBSD: patch-ad,v 1.6 2001/04/24 16:59:35 jlam Exp $
--- src/killall.c.orig Sat Mar 31 05:26:47 2001
+++ src/killall.c
@@ -18,10 +18,10 @@
#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 +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
okay = fscanf (file, "%*d (%[^)]", comm) == 1;
+#endif
(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
+ 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
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;
|