Pull up following revision(s) (requested by christos in ticket #677): lib/libc/sys/kqueue.2: revision 1.34 sys/kern/kern_event.c: revision 1.83 put the exit code of the process in data, like FreeBSD does. -- say that we put the exit code in data.diff -r1.33 -r1.33.8.1 src/lib/libc/sys/kqueue.2
(snj)
--- src/lib/libc/sys/kqueue.2 2012/11/24 15:16:52 1.33
+++ src/lib/libc/sys/kqueue.2 2015/04/14 04:39:58 1.33.8.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | .\" $NetBSD: kqueue.2,v 1.33 2012/11/24 15:16:52 christos Exp $ | 1 | .\" $NetBSD: kqueue.2,v 1.33.8.1 2015/04/14 04:39:58 snj Exp $ | |
2 | .\" | 2 | .\" | |
3 | .\" Copyright (c) 2000 Jonathan Lemon | 3 | .\" Copyright (c) 2000 Jonathan Lemon | |
4 | .\" All rights reserved. | 4 | .\" All rights reserved. | |
5 | .\" | 5 | .\" | |
6 | .\" Copyright (c) 2001, 2002, 2003 The NetBSD Foundation, Inc. | 6 | .\" Copyright (c) 2001, 2002, 2003 The NetBSD Foundation, Inc. | |
7 | .\" All rights reserved. | 7 | .\" All rights reserved. | |
8 | .\" | 8 | .\" | |
9 | .\" Portions of this documentation is derived from text contributed by | 9 | .\" Portions of this documentation is derived from text contributed by | |
10 | .\" Luke Mewburn. | 10 | .\" Luke Mewburn. | |
11 | .\" | 11 | .\" | |
12 | .\" Redistribution and use in source and binary forms, with or without | 12 | .\" Redistribution and use in source and binary forms, with or without | |
13 | .\" modification, are permitted provided that the following conditions | 13 | .\" modification, are permitted provided that the following conditions | |
14 | .\" are met: | 14 | .\" are met: | |
@@ -22,27 +22,27 @@ | @@ -22,27 +22,27 @@ | |||
22 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 22 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
23 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 23 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
24 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | 24 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |
25 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 25 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
26 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 26 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
27 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 27 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
28 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 28 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
29 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 29 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
30 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 30 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
31 | .\" SUCH DAMAGE. | 31 | .\" SUCH DAMAGE. | |
32 | .\" | 32 | .\" | |
33 | .\" $FreeBSD: src/lib/libc/sys/kqueue.2,v 1.22 2001/06/27 19:55:57 dd Exp $ | 33 | .\" $FreeBSD: src/lib/libc/sys/kqueue.2,v 1.22 2001/06/27 19:55:57 dd Exp $ | |
34 | .\" | 34 | .\" | |
35 | .Dd November 24, 2012 | 35 | .Dd March 2, 2015 | |
36 | .Dt KQUEUE 2 | 36 | .Dt KQUEUE 2 | |
37 | .Os | 37 | .Os | |
38 | .Sh NAME | 38 | .Sh NAME | |
39 | .Nm kqueue , | 39 | .Nm kqueue , | |
40 | .Nm kqueue1 , | 40 | .Nm kqueue1 , | |
41 | .Nm kevent | 41 | .Nm kevent | |
42 | .Nd kernel event notification mechanism | 42 | .Nd kernel event notification mechanism | |
43 | .Sh LIBRARY | 43 | .Sh LIBRARY | |
44 | .Lb libc | 44 | .Lb libc | |
45 | .Sh SYNOPSIS | 45 | .Sh SYNOPSIS | |
46 | .In sys/event.h | 46 | .In sys/event.h | |
47 | .In sys/time.h | 47 | .In sys/time.h | |
48 | .Ft int | 48 | .Ft int | |
@@ -403,26 +403,28 @@ or the underlying fileystem was unmounte | @@ -403,26 +403,28 @@ or the underlying fileystem was unmounte | |||
403 | On return, | 403 | On return, | |
404 | .Va fflags | 404 | .Va fflags | |
405 | contains the events which triggered the filter. | 405 | contains the events which triggered the filter. | |
406 | .It EVFILT_PROC | 406 | .It EVFILT_PROC | |
407 | Takes the process ID to monitor as the identifier and the events to watch for | 407 | Takes the process ID to monitor as the identifier and the events to watch for | |
408 | in | 408 | in | |
409 | .Va fflags , | 409 | .Va fflags , | |
410 | and returns when the process performs one or more of the requested events. | 410 | and returns when the process performs one or more of the requested events. | |
411 | If a process can normally see another process, it can attach an event to it. | 411 | If a process can normally see another process, it can attach an event to it. | |
412 | The events to monitor are: | 412 | The events to monitor are: | |
413 | .Bl -tag -width XXNOTE_TRACKERR | 413 | .Bl -tag -width XXNOTE_TRACKERR | |
414 | .It NOTE_EXIT | 414 | .It NOTE_EXIT | |
415 | The process has exited. | 415 | The process has exited. | |
416 | The exit code of the process is stored in | |||
417 | .Va data . | |||
416 | .It NOTE_FORK | 418 | .It NOTE_FORK | |
417 | The process has called | 419 | The process has called | |
418 | .Fn fork . | 420 | .Fn fork . | |
419 | .It NOTE_EXEC | 421 | .It NOTE_EXEC | |
420 | The process has executed a new process via | 422 | The process has executed a new process via | |
421 | .Xr execve 2 | 423 | .Xr execve 2 | |
422 | or similar call. | 424 | or similar call. | |
423 | .It NOTE_TRACK | 425 | .It NOTE_TRACK | |
424 | Follow a process across | 426 | Follow a process across | |
425 | .Fn fork | 427 | .Fn fork | |
426 | calls. | 428 | calls. | |
427 | The parent process will return with NOTE_TRACK set in the | 429 | The parent process will return with NOTE_TRACK set in the | |
428 | .Va fflags | 430 | .Va fflags |
--- src/sys/kern/kern_event.c 2014/06/24 14:42:43 1.80
+++ src/sys/kern/kern_event.c 2015/04/14 04:39:58 1.80.2.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: kern_event.c,v 1.80 2014/06/24 14:42:43 maxv Exp $ */ | 1 | /* $NetBSD: kern_event.c,v 1.80.2.1 2015/04/14 04:39:58 snj Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Andrew Doran. | 8 | * by Andrew Doran. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -48,27 +48,27 @@ | @@ -48,27 +48,27 @@ | |||
48 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | 48 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |
49 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 49 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
50 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 50 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
51 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 51 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
52 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 52 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
53 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 53 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
54 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 54 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
55 | * SUCH DAMAGE. | 55 | * SUCH DAMAGE. | |
56 | * | 56 | * | |
57 | * FreeBSD: src/sys/kern/kern_event.c,v 1.27 2001/07/05 17:10:44 rwatson Exp | 57 | * FreeBSD: src/sys/kern/kern_event.c,v 1.27 2001/07/05 17:10:44 rwatson Exp | |
58 | */ | 58 | */ | |
59 | 59 | |||
60 | #include <sys/cdefs.h> | 60 | #include <sys/cdefs.h> | |
61 | __KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.80 2014/06/24 14:42:43 maxv Exp $"); | 61 | __KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.80.2.1 2015/04/14 04:39:58 snj Exp $"); | |
62 | 62 | |||
63 | #include <sys/param.h> | 63 | #include <sys/param.h> | |
64 | #include <sys/systm.h> | 64 | #include <sys/systm.h> | |
65 | #include <sys/kernel.h> | 65 | #include <sys/kernel.h> | |
66 | #include <sys/proc.h> | 66 | #include <sys/proc.h> | |
67 | #include <sys/file.h> | 67 | #include <sys/file.h> | |
68 | #include <sys/select.h> | 68 | #include <sys/select.h> | |
69 | #include <sys/queue.h> | 69 | #include <sys/queue.h> | |
70 | #include <sys/event.h> | 70 | #include <sys/event.h> | |
71 | #include <sys/eventvar.h> | 71 | #include <sys/eventvar.h> | |
72 | #include <sys/poll.h> | 72 | #include <sys/poll.h> | |
73 | #include <sys/kmem.h> | 73 | #include <sys/kmem.h> | |
74 | #include <sys/stat.h> | 74 | #include <sys/stat.h> | |
@@ -538,26 +538,30 @@ filt_proc(struct knote *kn, long hint) | @@ -538,26 +538,30 @@ filt_proc(struct knote *kn, long hint) | |||
538 | struct kevent kev; | 538 | struct kevent kev; | |
539 | struct kqueue *kq; | 539 | struct kqueue *kq; | |
540 | int error; | 540 | int error; | |
541 | 541 | |||
542 | event = (u_int)hint & NOTE_PCTRLMASK; | 542 | event = (u_int)hint & NOTE_PCTRLMASK; | |
543 | kq = kn->kn_kq; | 543 | kq = kn->kn_kq; | |
544 | fflag = 0; | 544 | fflag = 0; | |
545 | 545 | |||
546 | /* If the user is interested in this event, record it. */ | 546 | /* If the user is interested in this event, record it. */ | |
547 | if (kn->kn_sfflags & event) | 547 | if (kn->kn_sfflags & event) | |
548 | fflag |= event; | 548 | fflag |= event; | |
549 | 549 | |||
550 | if (event == NOTE_EXIT) { | 550 | if (event == NOTE_EXIT) { | |
551 | struct proc *p = kn->kn_obj; | |||
552 | ||||
553 | if (p != NULL) | |||
554 | kn->kn_data = p->p_xstat; | |||
551 | /* | 555 | /* | |
552 | * Process is gone, so flag the event as finished. | 556 | * Process is gone, so flag the event as finished. | |
553 | * | 557 | * | |
554 | * Detach the knote from watched process and mark | 558 | * Detach the knote from watched process and mark | |
555 | * it as such. We can't leave this to kqueue_scan(), | 559 | * it as such. We can't leave this to kqueue_scan(), | |
556 | * since the process might not exist by then. And we | 560 | * since the process might not exist by then. And we | |
557 | * have to do this now, since psignal KNOTE() is called | 561 | * have to do this now, since psignal KNOTE() is called | |
558 | * also for zombies and we might end up reading freed | 562 | * also for zombies and we might end up reading freed | |
559 | * memory if the kevent would already be picked up | 563 | * memory if the kevent would already be picked up | |
560 | * and knote g/c'ed. | 564 | * and knote g/c'ed. | |
561 | */ | 565 | */ | |
562 | filt_procdetach(kn); | 566 | filt_procdetach(kn); | |
563 | 567 |