=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/pkill/pkill.c,v retrieving revision 1.3 retrieving revision 1.4 diff -c -r1.3 -r1.4 *** src/usr.bin/pkill/pkill.c 2004/03/12 00:19:48 1.3 --- src/usr.bin/pkill/pkill.c 2004/06/24 18:04:45 1.4 *************** *** 1,4 **** ! /* $OpenBSD: pkill.c,v 1.3 2004/03/12 00:19:48 deraadt Exp $ */ /* $NetBSD: pkill.c,v 1.5 2002/10/27 11:49:34 kleink Exp $ */ /*- --- 1,4 ---- ! /* $OpenBSD: pkill.c,v 1.4 2004/06/24 18:04:45 millert Exp $ */ /* $NetBSD: pkill.c,v 1.5 2002/10/27 11:49:34 kleink Exp $ */ /*- *************** *** 38,44 **** */ #ifndef lint ! static const char rcsid[] = "$OpenBSD: pkill.c,v 1.3 2004/03/12 00:19:48 deraadt Exp $"; #endif /* !lint */ #include --- 38,44 ---- */ #ifndef lint ! static const char rcsid[] = "$OpenBSD: pkill.c,v 1.4 2004/06/24 18:04:45 millert Exp $"; #endif /* !lint */ #include *************** *** 107,114 **** int main(int, char **); void usage(void); ! void killact(struct kinfo_proc2 *); ! void grepact(struct kinfo_proc2 *); void makelist(struct listhead *, enum listtype, char *); extern char *__progname; --- 107,114 ---- int main(int, char **); void usage(void); ! int killact(struct kinfo_proc2 *); ! int grepact(struct kinfo_proc2 *); void makelist(struct listhead *, enum listtype, char *); extern char *__progname; *************** *** 120,126 **** extern int optind; char buf[_POSIX2_LINE_MAX], *mstr, **pargv, *p, *q; int i, j, ch, bestidx, rv, criteria; ! void (*action)(struct kinfo_proc2 *); struct kinfo_proc2 *kp; struct list *li; u_int32_t bestsec, bestusec; --- 120,126 ---- extern int optind; char buf[_POSIX2_LINE_MAX], *mstr, **pargv, *p, *q; int i, j, ch, bestidx, rv, criteria; ! int (*action)(struct kinfo_proc2 *); struct kinfo_proc2 *kp; struct list *li; u_int32_t bestsec, bestusec; *************** *** 384,390 **** /* * Take the appropriate action for each matched process, if any. */ ! for (i = 0, rv = 0, kp = plist; i < nproc; i++, kp++) { if (kp->p_pid == mypid) continue; if (selected[i]) { --- 384,390 ---- /* * Take the appropriate action for each matched process, if any. */ ! for (i = 0, rv = STATUS_NOMATCH, kp = plist; i < nproc; i++, kp++) { if (kp->p_pid == mypid) continue; if (selected[i]) { *************** *** 396,406 **** if ((kp->p_flag & P_SYSTEM) != 0) continue; ! rv = 1; ! (*action)(kp); } ! exit(rv ? STATUS_MATCH : STATUS_NOMATCH); } void --- 396,408 ---- if ((kp->p_flag & P_SYSTEM) != 0) continue; ! if ((*action)(kp) == -1) ! rv = STATUS_ERROR; ! else if (rv != STATUS_ERROR) ! rv = STATUS_MATCH; } ! exit(rv); } void *************** *** 419,440 **** exit(STATUS_ERROR); } ! void killact(struct kinfo_proc2 *kp) { ! if (kill(kp->p_pid, signum) == -1) ! err(STATUS_ERROR, "signalling pid %d", (int)kp->p_pid); } ! void grepact(struct kinfo_proc2 *kp) { char **argv; if (longfmt && matchargs) { if ((argv = kvm_getargv2(kd, kp, 0)) == NULL) ! return; printf("%d ", (int)kp->p_pid); for (; *argv != NULL; argv++) { --- 421,445 ---- exit(STATUS_ERROR); } ! int killact(struct kinfo_proc2 *kp) { ! if (kill(kp->p_pid, signum) == -1) { ! warn("signalling pid %d", (int)kp->p_pid); ! return (-1); ! } ! return (0); } ! int grepact(struct kinfo_proc2 *kp) { char **argv; if (longfmt && matchargs) { if ((argv = kvm_getargv2(kd, kp, 0)) == NULL) ! return (-1); printf("%d ", (int)kp->p_pid); for (; *argv != NULL; argv++) { *************** *** 448,453 **** --- 453,459 ---- printf("%d", (int)kp->p_pid); printf("%s", delim); + return (0); } void