Remove old patches. As theo put it, patches is not a dropping ground.
This commit is contained in:
parent
c7effa9847
commit
4b2d95c314
@ -1,6 +0,0 @@
|
||||
--- Makefile.orig Sun May 30 15:47:24 1999
|
||||
+++ Makefile Sun May 30 15:47:24 1999
|
||||
@@ -0,0 +1,3 @@
|
||||
+PROG = zap
|
||||
+
|
||||
+.include <bsd.prog.mk>
|
@ -1,11 +0,0 @@
|
||||
--- system.c.orig Sat Dec 20 11:08:08 1997
|
||||
+++ system.c Sun May 30 15:47:24 1999
|
||||
@@ -8,7 +8,7 @@
|
||||
char *s;
|
||||
{
|
||||
int status, pid, w, tty;
|
||||
- int (*istat)(), (*qstat)();
|
||||
+ void (*istat)(int), (*qstat)(int);
|
||||
extern char *progname;
|
||||
|
||||
fflush(stdout);
|
@ -1,151 +0,0 @@
|
||||
--- zap-slashproc.c.orig Sun May 30 15:47:25 1999
|
||||
+++ zap-slashproc.c Sun May 30 15:47:25 1999
|
||||
@@ -0,0 +1,148 @@
|
||||
+/*
|
||||
+ * zap -- fast kill by name using SVR4 /proc
|
||||
+ * Based on an earlier program of the same name
|
||||
+ * by Kernighan & Pike, in their classic book
|
||||
+ * The UNIX Programming Environment, 1984.
|
||||
+ */
|
||||
+
|
||||
+#ident "$Id: patch-03,v 1.2 1999/05/30 20:44:39 ian Exp $"
|
||||
+
|
||||
+#include <stdio.h>
|
||||
+#include <dirent.h>
|
||||
+#include <errno.h>
|
||||
+#include <sys/types.h>
|
||||
+#include <sys/fault.h>
|
||||
+#include <sys/syscall.h>
|
||||
+#include <sys/procfs.h>
|
||||
+
|
||||
+#define STREQ(s,t) (*(s)==*(t) && strcmp(s, t)==0)
|
||||
+
|
||||
+char *progname;
|
||||
+int debug;
|
||||
+void exit();
|
||||
+int signum = 1; /* hangup */
|
||||
+extern int errno;
|
||||
+int permis = 0;
|
||||
+
|
||||
+/*
|
||||
+ * warn - print best error message possible and clear errno
|
||||
+ */
|
||||
+warn(s1, s2)
|
||||
+char *s1;
|
||||
+char *s2;
|
||||
+{
|
||||
+ char *cmdname;
|
||||
+ extern int sys_nerr;
|
||||
+ extern char *sys_errlist[];
|
||||
+ extern char *progname;
|
||||
+ extern char *getenv();
|
||||
+
|
||||
+ cmdname = getenv("CMDNAME");
|
||||
+ if (cmdname != NULL && *cmdname != '\0')
|
||||
+ (void) fprintf(stderr, "%s:", cmdname); /* No space after :. */
|
||||
+ if (progname != NULL)
|
||||
+ (void) fprintf(stderr, "%s: ", progname);
|
||||
+ (void) fprintf(stderr, s1, s2);
|
||||
+ if (errno > 0)
|
||||
+ if (errno < sys_nerr)
|
||||
+ (void) fprintf(stderr, " (%s)", sys_errlist[errno]);
|
||||
+ else
|
||||
+ (void) fprintf(stderr, " (errno=%d)", errno);
|
||||
+ (void) fputc('\n', stderr);
|
||||
+ errno = 0;
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * die - print best error message possible and exit
|
||||
+ */
|
||||
+die(s1, s2)
|
||||
+char *s1;
|
||||
+char *s2;
|
||||
+{
|
||||
+ warn(s1, s2);
|
||||
+ exit(1);
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * main - parse arguments and handle options
|
||||
+ */
|
||||
+main(argc, argv)
|
||||
+int argc;
|
||||
+char *argv[];
|
||||
+{
|
||||
+ int c;
|
||||
+ FILE *in;
|
||||
+ extern int optind;
|
||||
+ extern char *optarg;
|
||||
+ int errors = 0;
|
||||
+
|
||||
+ progname = argv[0];
|
||||
+
|
||||
+ while ((c = getopt(argc, argv, "ds:")) != EOF)
|
||||
+ switch (c) {
|
||||
+ case 's':
|
||||
+ signum = atoi(argv[optind]); /* TODO names */
|
||||
+ break;
|
||||
+ case 'd':
|
||||
+ ++debug;
|
||||
+ break;
|
||||
+ case '?':
|
||||
+ default:
|
||||
+ errors++;
|
||||
+ break;
|
||||
+ }
|
||||
+ if (errors) {
|
||||
+ (void) fprintf(stderr, "usage: %s [-s signum] procname ...\n", progname);
|
||||
+ exit(2);
|
||||
+ }
|
||||
+
|
||||
+ if (chdir("/proc") < 0) {
|
||||
+ perror("chdir: /proc");
|
||||
+ exit(1);
|
||||
+ }
|
||||
+
|
||||
+ if (optind >= argc)
|
||||
+ die("Must provide a process name", "");
|
||||
+ else
|
||||
+ for (; optind < argc; optind++)
|
||||
+ process(argv[optind]);
|
||||
+ if (permis) {
|
||||
+ warn("One or more process files unreadable");
|
||||
+ ++errors;
|
||||
+ }
|
||||
+ exit(errors);
|
||||
+}
|
||||
+
|
||||
+
|
||||
+/*
|
||||
+ * process - process one process
|
||||
+ */
|
||||
+process(name)
|
||||
+char *name;
|
||||
+{
|
||||
+ int fd;
|
||||
+ DIR *dirp = opendir(".");
|
||||
+ struct dirent *dp;
|
||||
+ prpsinfo_t procbuf;
|
||||
+
|
||||
+ while ((dp = readdir(dirp)) != NULL)
|
||||
+ if (dp->d_name[0] != '.') {
|
||||
+ if ((fd = open(dp->d_name, 0)) < 0) {
|
||||
+ if (errno == EACCES)
|
||||
+ ++permis;
|
||||
+ continue; /* it just exited */
|
||||
+ }
|
||||
+ if (ioctl(fd, PIOCPSINFO, &procbuf) < 0)
|
||||
+ continue; /* exited, or permission denied */
|
||||
+ if (strstr(procbuf.pr_fname, name) != 0)
|
||||
+ if (kill(procbuf.pr_pid, signum) < 0) {
|
||||
+ char msgbuf[128];
|
||||
+ sprintf(msgbuf, "kill: process %d",
|
||||
+ procbuf.pr_pid);
|
||||
+ perror(msgbuf);
|
||||
+ }
|
||||
+ (void) close(fd);
|
||||
+ }
|
||||
+ (void)closedir( dirp );
|
||||
+ return 0;
|
||||
+}
|
@ -1,52 +0,0 @@
|
||||
--- zap.1.orig Sun May 30 15:47:25 1999
|
||||
+++ zap.1 Sun May 30 16:33:31 1999
|
||||
@@ -0,0 +1,49 @@
|
||||
+.Dd 1984
|
||||
+.Os OpenBSD 2.3
|
||||
+.Dt ZAP 1 UPM
|
||||
+.Sh NAME
|
||||
+.Nm zap
|
||||
+.Nd interactive process killer
|
||||
+.Sh SYNOPSIS
|
||||
+.Nm zap [-s NUM] [-y] string [...]]
|
||||
+.Sh DESCRIPTION
|
||||
+.Nm Zap
|
||||
+takes one or more strings, looks for each in the output of a
|
||||
+.Nm ps
|
||||
+command that it runs, and for each process whose
|
||||
+.Nm ps
|
||||
+line matches the string, prints the line as a prompt.
|
||||
+If you reply with a
|
||||
+.Nm y,
|
||||
+the program attempts to deliver a signal SIGERM to the given process.
|
||||
+If a zero-length
|
||||
+.Nm string
|
||||
+is given, then every process will be prompted for.
|
||||
+.PP
|
||||
+The
|
||||
+.B -y
|
||||
+option tells the program to just do it, not to ask for confirmation.
|
||||
+It makes the program non-interactive.
|
||||
+.PP
|
||||
+The
|
||||
+.B -s
|
||||
+.I signum
|
||||
+option takes a numeric (only) argument, which is the signal number
|
||||
+to send. In the absence of this option, SIGTERM is sent.
|
||||
+.Sh EXAMPLES
|
||||
+.Nm zap pppd
|
||||
+.br
|
||||
+Assuming you have permissions, will send a TERMinate signal to any and all
|
||||
+.Nm pppd
|
||||
+processes.
|
||||
+.Sh SEE ALSO
|
||||
+.Nm ps(1)
|
||||
+.Sh HISTORY
|
||||
+The
|
||||
+.Nm zap
|
||||
+command appears in the book
|
||||
+.Nm The UNIX Programming Environment,
|
||||
+Kernighan and Pike, 1984, Prentice-Hall.
|
||||
+.Sh AUTHORS
|
||||
+Brian Kernighan and Rob Pike - program.
|
||||
+Ian Darwin - this manual page.
|
@ -1,98 +0,0 @@
|
||||
--- zap.c.orig Sat Dec 20 11:08:09 1997
|
||||
+++ zap.c Sun May 30 16:19:56 1999
|
||||
@@ -2,36 +2,81 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
+
|
||||
char *progname; /* program name for error message */
|
||||
-char *ps = "ps -ag"; /* system dependent */
|
||||
+char *ps = "ps -ax"; /* system dependent */
|
||||
+int progpid;
|
||||
+
|
||||
+FILE *efopen(char *file, char *mode);
|
||||
|
||||
-main(argc, argv)
|
||||
- int argc;
|
||||
- char *argv[];
|
||||
+main(int argc, char **argv)
|
||||
{
|
||||
FILE *fin, *popen();
|
||||
- char buf[BUFSIZ];
|
||||
- int pid;
|
||||
+ char buf[BUFSIZ]; /* a line to read */
|
||||
+ int errors = 0; /* for getopt */
|
||||
+ int c = 0; /* from getopt */
|
||||
+ extern int optind; /* from getopt */
|
||||
+ extern char* optarg;/* from getopt */
|
||||
+ int pid; /* target PID */
|
||||
+ int interact = 1; /* ? ask : just do it */
|
||||
+ int debug = 0; /* print debugging? (unused) */
|
||||
+ int signum = SIGTERM; /* how shall I tell thee? */
|
||||
|
||||
progname = argv[0];
|
||||
+ progpid = getpid();
|
||||
+
|
||||
+ while ((c = getopt(argc, argv, "ds:y")) != EOF) {
|
||||
+ switch (c) {
|
||||
+ case 's':
|
||||
+ signum = atoi(optarg); /* TODO name lookup like kill(1) */
|
||||
+ break;
|
||||
+ case 'd':
|
||||
+ ++debug;
|
||||
+ break;
|
||||
+ case 'y':
|
||||
+ interact = 0;
|
||||
+ break;
|
||||
+ case '?':
|
||||
+ default:
|
||||
+ errors++;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ if (errors || (argc-optind<1)) {
|
||||
+ (void) fprintf(stderr, "usage: %s [-s signum] processname ...\n", progname);
|
||||
+ exit(2);
|
||||
+ }
|
||||
+
|
||||
if ((fin = popen(ps, "r")) == NULL) {
|
||||
fprintf(stderr, "%s: can't run %s\n", progname, ps);
|
||||
exit(1);
|
||||
}
|
||||
fgets(buf, sizeof buf, fin); /* get header line */
|
||||
fprintf(stderr, "%s", buf);
|
||||
- while (fgets(buf, sizeof buf, fin) != NULL)
|
||||
- if (argc == 1 || strindex(buf, argv[1]) >= 0) {
|
||||
- buf[strlen(buf)-1] = '\0'; /* suppress \n */
|
||||
- fprintf(stderr, "%s? ", buf);
|
||||
- if (ttyin() == 'y') {
|
||||
- sscanf(buf, "%d", &pid);
|
||||
- kill(pid, SIGKILL);
|
||||
+
|
||||
+ /* Read a line from ps, process it. */
|
||||
+ while (fgets(buf, sizeof buf, fin) != NULL) {
|
||||
+ buf[strlen(buf)-1] = '\0'; /* suppress \n */
|
||||
+ if (strstr(buf, argv[optind]) != NULL &&
|
||||
+ (pid = atoi(buf)) != progpid) {
|
||||
+
|
||||
+ fprintf(stderr, "%s", buf);
|
||||
+
|
||||
+ if (interact) {
|
||||
+ fprintf(stderr, "? ");
|
||||
+ if (ttyin() == 'y') {
|
||||
+ if (kill(pid, signum)<0)
|
||||
+ perror(buf);
|
||||
+ }
|
||||
+ } else {
|
||||
+ fprintf(stderr, "\n");
|
||||
+ if (kill(pid, signum)<0)
|
||||
+ perror(buf);
|
||||
}
|
||||
}
|
||||
+ }
|
||||
exit(0);
|
||||
}
|
||||
|
||||
#include "ttyin2.c"
|
||||
-#include "strindex.c"
|
||||
#include "efopen.c"
|
Loading…
Reference in New Issue
Block a user