Lines Matching +full:- +full:- +full:pid
1 /*-
2 * Copyright (c) 2004-2009, Jilles Tjoelker
51 struct pid { struct
52 RB_ENTRY(pid) entry;
53 pid_t pid; member
57 pidcmp(const struct pid *a, const struct pid *b) in pidcmp()
59 return (a->pid > b->pid ? 1 : a->pid < b->pid ? -1 : 0); in pidcmp()
62 RB_HEAD(pidtree, pid);
64 RB_GENERATE_STATIC(pidtree, pid, entry, pidcmp);
69 fprintf(stderr, "usage: pwait [-t timeout] [-opv] pid ...\n"); in usage()
74 * pwait - wait for processes to terminate
81 struct pid k, *p; in main()
85 long pid; in main() local
96 while ((opt = getopt(argc, argv, "opt:v")) != -1) { in main()
134 timeout -= (time_t)timeout; in main()
147 argc -= optind; in main()
173 pid = strtol(s, &end, 10); in main()
174 if (pid < 0 || pid > pid_max || *end != '\0' || errno != 0) { in main()
178 if (pid == mypid) { in main()
179 warnx("%s: skipping my own pid", s); in main()
185 p->pid = pid; in main()
191 EV_SET(e + nleft, pid, EVFILT_PROC, EV_ADD, NOTE_EXIT, 0, NULL); in main()
192 if (kevent(kq, e + nleft, 1, NULL, 0, NULL) == -1) { in main()
195 warn("%ld", pid); in main()
210 if (kevent(kq, e + nleft, 1, NULL, 0, NULL) == -1) { in main()
215 if (setitimer(ITIMER_REAL, &itv, NULL) == -1) { in main()
222 if (n == -1) { in main()
232 pid = e[i].ident; in main()
237 pid, WEXITSTATUS(status)); in main()
240 pid, WTERMSIG(status)); in main()
242 printf("%ld: terminated.\n", pid); in main()
245 k.pid = pid; in main()
251 --nleft; in main()
256 printf("%d\n", p->pid); in main()