05-02-06 12:13 AM
here is the cvs diff -up output.
-- steffen
Index: Makefile
========================================
===========================
RCS file: /cvs/src/usr.bin/pkill/Makefile,v
retrieving revision 1.1
diff -u -p -r1.1 Makefile
--- Makefile 6 Jan 2004 20:07:49 -0000 1.1
+++ Makefile 1 May 2006 20:22:26 -0000
@@ -9,6 +9,8 @@ LDADD+= -lkvm
DPADD+= ${LIBKVM}
LINKS+= ${BINDIR}/pkill ${BINDIR}/pgrep
+LINKS+= ${BINDIR}/pkill ${BINDIR}/psig
MLINKS+=pkill.1 pgrep.1
+MLINKS+=pkill.1 psig.1
.include <bsd.prog.mk>
Index: pkill.1
========================================
===========================
RCS file: /cvs/src/usr.bin/pkill/pkill.1,v
retrieving revision 1.7
diff -u -p -r1.7 pkill.1
--- pkill.1 16 Jul 2005 11:58:10 -0000 1.7
+++ pkill.1 1 May 2006 20:22:26 -0000
@@ -39,8 +39,8 @@
.Dt PKILL 1
.Os
.Sh NAME
-.Nm pgrep , pkill
-.Nd find or signal processes by name
+.Nm pgrep , pkill , psig
+.Nd find, signal or show signal settings (of) processes by name
.Sh SYNOPSIS
.Nm pgrep
.Op Fl flnvx
@@ -64,6 +64,16 @@
.Op Fl U Ar uid
.Op Fl u Ar euid
.Op Ar pattern ...
+.Nm psig
+.Op Fl fnvx
+.Op Fl G Ar gid
+.Op Fl g Ar pgrp
+.Op Fl P Ar ppid
+.Op Fl s Ar sid
+.Op Fl t Ar tty
+.Op Fl U Ar uid
+.Op Fl u Ar euid
+.Op Ar pattern ..
.Sh DESCRIPTION
The
.Nm pgrep
@@ -76,6 +86,12 @@ The
command searches the process table on the running system and signals all
processes that match the criteria given on the command line.
.Pp
+The
+.Nm psig
+command searches the process table on the running system and shows the
+signal settings of all processes that match the criteria given on the
+command line.
+.Pp
The following options are available:
.Bl -tag -width Ds
.It Fl d Ar delim
@@ -196,6 +212,16 @@ first appeared in
.Ox 3.5 .
They are modelled after utilities of the same name that appeared in Sun
Solaris 7.
+.Pp
+.Nm psig
+first appeared in
+.Ox 4.0 .
+It is modelled after a utility of the same name that is shipped with in Sun
+Solaris 8, but is not exactly the same.
+
.Sh AUTHORS
.An Andrew Doran
-.Aq ad@NetBSD.org .
+.Aq ad@NetBSD.org ,
+.Pp
+.An Steffen Wendzel
+.Aq cdp@doomed-reality.org .
Index: pkill.c
========================================
===========================
RCS file: /cvs/src/usr.bin/pkill/pkill.c,v
retrieving revision 1.14
diff -u -p -r1.14 pkill.c
--- pkill.c 16 Jul 2005 11:48:46 -0000 1.14
+++ pkill.c 1 May 2006 20:22:28 -0000
@@ -88,6 +88,7 @@ char *selected;
char *delim = "\n";
int nproc;
int pgrep;
+int psig;
int signum = SIGTERM;
int newest;
int inverse;
@@ -109,6 +110,7 @@ int main(int, char **);
void usage(void);
int killact(struct kinfo_proc2 *, int);
int grepact(struct kinfo_proc2 *, int);
+int sigact(struct kinfo_proc2 *, int);
void makelist(struct listhead *, enum listtype, char *);
extern char *__progname;
@@ -130,6 +132,9 @@ main(int argc, char **argv)
if (strcmp(__progname, "pgrep") == 0) {
action = grepact;
pgrep = 1;
+ } else if (strcmp(__progname, "psig") == 0) {
+ action = sigact;
+ psig = 1;
} else {
action = killact;
p = argv[1];
@@ -460,6 +465,130 @@ grepact(struct kinfo_proc2 *kp, int prin
else
printf("%d", (int)kp->p_pid);
+ return (0);
+}
+
+void
+print_signals(u_int32_t mask)
+{
+ u_int32_t testmask;
+ unsigned short n;
+
+ for (testmask = 1, n = 0; n < 32; n++) {
+ if (mask & (testmask << n)) {
+ switch(n+1) {
+ case SIGHUP:
+ printf("HUP(");
+ break;
+ case SIGINT:
+ printf("INT(");
+ break;
+ case SIGQUIT:
+ printf("QUIT(");
+ break;
+ case SIGILL:
+ printf("ILL(");
+ break;
+ case SIGTRAP:
+ printf("TRAP(");
+ break;
+ case SIGABRT:
+ printf("ABRT(");
+ break;
+ case SIGEMT:
+ printf("EMT(");
+ break;
+ case SIGFPE:
+ printf("FPE(");
+ break;
+ case SIGBUS:
+ printf("BUS(");
+ break;
+ case SIGSEGV:
+ printf("SEGV(");
+ break;
+ case SIGSYS:
+ printf("SYS(");
+ break;
+ case SIGPIPE:
+ printf("PIPE(");
+ break;
+ case SIGALRM:
+ printf("ALRM(");
+ break;
+ case SIGTERM:
+ printf("TERM(");
+ break;
+ case SIGURG:
+ printf("URG(");
+ break;
+ case SIGSTOP:
+ printf("STOP(");
+ break;
+ case SIGTSTP:
+ printf("TSTP(");
+ break;
+ case SIGCONT:
+ printf("CONT(");
+ break;
+ case SIGCHLD:
+ printf("CHLD(");
+ break;
+ case SIGTTIN:
+ printf("TTIN(");
+ break;
+ case SIGTTOU:
+ printf("TTOU(");
+ break;
+ case SIGIO:
+ printf("IO(");
+ break;
+ case SIGXCPU:
+ printf("XCPU(");
+ break;
+ case SIGXFSZ:
+ printf("XFSZ(");
+ break;
+ case SIGVTALRM:
+ printf("VTALRM(");
+ break;
+ case SIGPROF:
+ printf("PROF(");
+ break;
+ case SIGWINCH:
+ printf("WINCH(");
+ break;
+ case SIGINFO:
+ printf("INFO(");
+ break;
+ case SIGUSR1:
+ printf("USR1(");
+ break;
+ case SIGUSR2:
+ printf("USR2(");
+ break;
+ default:
+ printf("UNKNOWN(");
+ break;
+ }
+ printf("%i) ", n);
+ }
+ }
+}
+
+int
+sigact(struct kinfo_proc2 *kp, int dummy)
+{
+
+ printf("command: %s, pid: %i\n", kp->p_comm, (int)kp->p_pid);
+ printf("\tsignal mask: ");
+ print_signals(kp->p_sigmask);
+ printf("\n\tignore mask: ");
+ print_signals(kp->p_sigignore);
+ printf("\n\tcatch mask: ");
+ print_signals(kp->p_sigcatch);
+ printf("\n");
+
return (0);
}
[ Post a follow-up to this message ]
|