| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: pwait.c,v 1.3 2015/03/03 19:59:48 christos Exp $ */ | | 1 | /* $NetBSD: pwait.c,v 1.4 2015/03/04 13:31:53 christos Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2004-2009, Jilles Tjoelker | | 4 | * Copyright (c) 2004-2009, Jilles Tjoelker |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with | | 7 | * Redistribution and use in source and binary forms, with |
8 | * or without modification, are permitted provided that the | | 8 | * or without modification, are permitted provided that the |
9 | * following conditions are met: | | 9 | * following conditions are met: |
10 | * | | 10 | * |
11 | * 1. Redistributions of source code must retain the above | | 11 | * 1. Redistributions of source code must retain the above |
12 | * copyright notice, this list of conditions and the | | 12 | * copyright notice, this list of conditions and the |
13 | * following disclaimer. | | 13 | * following disclaimer. |
14 | * 2. Redistributions in binary form must reproduce the | | 14 | * 2. Redistributions in binary form must reproduce the |
| @@ -27,27 +27,27 @@ | | | @@ -27,27 +27,27 @@ |
27 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | | 27 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
28 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | | 28 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | | 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE | | 31 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE |
32 | * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY | | 32 | * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY |
33 | * OF SUCH DAMAGE. | | 33 | * OF SUCH DAMAGE. |
34 | */ | | 34 | */ |
35 | | | 35 | |
36 | #include <sys/cdefs.h> | | 36 | #include <sys/cdefs.h> |
37 | #ifdef __FBSDID | | 37 | #ifdef __FBSDID |
38 | __FBSDID("$FreeBSD: head/bin/pwait/pwait.c 245506 2013-01-16 18:15:25Z delphij $"); | | 38 | __FBSDID("$FreeBSD: head/bin/pwait/pwait.c 245506 2013-01-16 18:15:25Z delphij $"); |
39 | #endif | | 39 | #endif |
40 | __RCSID("$NetBSD: pwait.c,v 1.3 2015/03/03 19:59:48 christos Exp $"); | | 40 | __RCSID("$NetBSD: pwait.c,v 1.4 2015/03/04 13:31:53 christos Exp $"); |
41 | | | 41 | |
42 | #include <sys/types.h> | | 42 | #include <sys/types.h> |
43 | #include <sys/event.h> | | 43 | #include <sys/event.h> |
44 | #include <sys/time.h> | | 44 | #include <sys/time.h> |
45 | #include <sys/wait.h> | | 45 | #include <sys/wait.h> |
46 | | | 46 | |
47 | #include <err.h> | | 47 | #include <err.h> |
48 | #include <errno.h> | | 48 | #include <errno.h> |
49 | #include <fcntl.h> | | 49 | #include <fcntl.h> |
50 | #include <signal.h> | | 50 | #include <signal.h> |
51 | #include <stdio.h> | | 51 | #include <stdio.h> |
52 | #include <stdlib.h> | | 52 | #include <stdlib.h> |
53 | #include <string.h> | | 53 | #include <string.h> |
| @@ -133,27 +133,27 @@ main(int argc, char *argv[]) | | | @@ -133,27 +133,27 @@ main(int argc, char *argv[]) |
133 | errno = 0; | | 133 | errno = 0; |
134 | pidl = strtol(s, &end, 10); | | 134 | pidl = strtol(s, &end, 10); |
135 | if (pidl < 0 || *end != '\0' || errno != 0) { | | 135 | if (pidl < 0 || *end != '\0' || errno != 0) { |
136 | warnx("%s: bad process id", s); | | 136 | warnx("%s: bad process id", s); |
137 | continue; | | 137 | continue; |
138 | } | | 138 | } |
139 | pid = (pid_t)pidl; | | 139 | pid = (pid_t)pidl; |
140 | duplicate = 0; | | 140 | duplicate = 0; |
141 | for (i = 0; i < nleft; i++) | | 141 | for (i = 0; i < nleft; i++) |
142 | if (e[i].ident == (uintptr_t)pid) | | 142 | if (e[i].ident == (uintptr_t)pid) |
143 | duplicate = 1; | | 143 | duplicate = 1; |
144 | if (!duplicate) { | | 144 | if (!duplicate) { |
145 | EV_SET(e + nleft, (uintptr_t)pid, EVFILT_PROC, EV_ADD, | | 145 | EV_SET(e + nleft, (uintptr_t)pid, EVFILT_PROC, EV_ADD, |
146 | NOTE_EXIT, 0, NULL); | | 146 | NOTE_EXIT, 0, 0); |
147 | if (kevent(kq, e + nleft, 1, NULL, 0, NULL) == -1) | | 147 | if (kevent(kq, e + nleft, 1, NULL, 0, NULL) == -1) |
148 | warn("%jd", (intmax_t)pid); | | 148 | warn("%jd", (intmax_t)pid); |
149 | else | | 149 | else |
150 | nleft++; | | 150 | nleft++; |
151 | } | | 151 | } |
152 | } | | 152 | } |
153 | | | 153 | |
154 | while (nleft > 0) { | | 154 | while (nleft > 0) { |
155 | int rv; | | 155 | int rv; |
156 | | | 156 | |
157 | switch (rv = kevent(kq, NULL, 0, e, nleft, tsp)) { | | 157 | switch (rv = kevent(kq, NULL, 0, e, nleft, tsp)) { |
158 | case 0: | | 158 | case 0: |
159 | if (verbose) | | 159 | if (verbose) |