mirror of
https://github.com/Stichting-MINIX-Research-Foundation/pkgsrc-ng.git
synced 2025-08-03 17:59:07 -04:00
80 lines
2.2 KiB
Plaintext
80 lines
2.2 KiB
Plaintext
$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;
|