Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/sys_procdesc.c
| Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | |||||
| * Open questions: | * Open questions: | ||||
| * | * | ||||
| * - Will we want to add a pidtoprocdesc(2) system call to allow process | * - Will we want to add a pidtoprocdesc(2) system call to allow process | ||||
| * descriptors to be created for processes without pdfork(2)? | * descriptors to be created for processes without pdfork(2)? | ||||
| */ | */ | ||||
| #include <sys/param.h> | #include <sys/param.h> | ||||
| #include <sys/capsicum.h> | #include <sys/capsicum.h> | ||||
| #include <sys/event.h> | |||||
| #include <sys/fcntl.h> | #include <sys/fcntl.h> | ||||
| #include <sys/file.h> | #include <sys/file.h> | ||||
| #include <sys/filedesc.h> | #include <sys/filedesc.h> | ||||
| #include <sys/imgact.h> | #include <sys/imgact.h> | ||||
| #include <sys/kernel.h> | #include <sys/kernel.h> | ||||
| #include <sys/lock.h> | #include <sys/lock.h> | ||||
| #include <sys/mutex.h> | #include <sys/mutex.h> | ||||
| #include <sys/poll.h> | #include <sys/poll.h> | ||||
| ▲ Show 20 Lines • Show All 267 Lines • ▼ Show 20 Lines | procdesc_exit(struct proc *p) | ||||
| if (pd->pd_fpcount == 0) { | if (pd->pd_fpcount == 0) { | ||||
| PROCDESC_UNLOCK(pd); | PROCDESC_UNLOCK(pd); | ||||
| pd->pd_proc = NULL; | pd->pd_proc = NULL; | ||||
| p->p_procdesc = NULL; | p->p_procdesc = NULL; | ||||
| procdesc_free(pd); | procdesc_free(pd); | ||||
| return (1); | return (1); | ||||
| } | } | ||||
| selwakeup(&pd->pd_selinfo); | selwakeup(&pd->pd_selinfo); | ||||
| KNOTE_LOCKED(&pd->pd_selinfo.si_note, NOTE_EXIT); | KNOTE_LOCKED(&pd->pd_selinfo.si_note, NOTE_EXIT | NOTE_PDSIGCHLD); | ||||
markj: In procdesc_kqops_event() there is a test, `if (event == NOTE_EXIT)`. Probably that needs to… | |||||
| PROCDESC_UNLOCK(pd); | PROCDESC_UNLOCK(pd); | ||||
| /* Wakeup all waiters for this procdesc' process exit. */ | /* Wakeup all waiters for this procdesc' process exit. */ | ||||
| wakeup(&p->p_procdesc); | wakeup(&p->p_procdesc); | ||||
| return (0); | return (0); | ||||
| } | } | ||||
| void | |||||
| procdesc_jobstate(struct proc *p) | |||||
| { | |||||
| struct procdesc *pd; | |||||
| PROC_LOCK_ASSERT(p, MA_OWNED); | |||||
| pd = p->p_procdesc; | |||||
| if (pd == NULL) | |||||
| return; | |||||
| PROCDESC_LOCK(pd); | |||||
| KNOTE_LOCKED(&pd->pd_selinfo.si_note, NOTE_PDSIGCHLD); | |||||
| PROCDESC_UNLOCK(pd); | |||||
| } | |||||
| /* | /* | ||||
| * When a process descriptor is reaped, perhaps as a result of close(), release | * When a process descriptor is reaped, perhaps as a result of close(), release | ||||
| * the process's reference on the process descriptor. | * the process's reference on the process descriptor. | ||||
| */ | */ | ||||
| void | void | ||||
| procdesc_reap(struct proc *p) | procdesc_reap(struct proc *p) | ||||
| { | { | ||||
| struct procdesc *pd; | struct procdesc *pd; | ||||
| ▲ Show 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | |||||
| procdesc_kqops_event(struct knote *kn, long hint) | procdesc_kqops_event(struct knote *kn, long hint) | ||||
| { | { | ||||
| struct procdesc *pd; | struct procdesc *pd; | ||||
| u_int event; | u_int event; | ||||
| pd = kn->kn_fp->f_data; | pd = kn->kn_fp->f_data; | ||||
| if (hint == 0) { | if (hint == 0) { | ||||
| /* | /* | ||||
| * Initial test after registration. Generate a NOTE_EXIT in | * Initial test after registration. Generate notes in | ||||
| * case the process already terminated before registration. | * case the process already terminated before registration. | ||||
| */ | */ | ||||
| event = pd->pd_flags & PDF_EXITED ? NOTE_EXIT : 0; | event = (pd->pd_flags & PDF_EXITED) != 0 ? (NOTE_EXIT | | ||||
| NOTE_PDSIGCHLD) : 0; | |||||
Done Inline ActionsShould this generate NOTE_PDSIGCHLD too? markj: Should this generate NOTE_PDSIGCHLD too? | |||||
| } else { | } else { | ||||
| /* Mask off extra data. */ | /* Mask off extra data. */ | ||||
| event = (u_int)hint & NOTE_PCTRLMASK; | event = (u_int)hint & NOTE_PCTRLMASK; | ||||
| } | } | ||||
| /* If the user is interested in this event, record it. */ | /* If the user is interested in this event, record it. */ | ||||
| if (kn->kn_sfflags & event) | if (kn->kn_sfflags & event) | ||||
| kn->kn_fflags |= event; | kn->kn_fflags |= event; | ||||
| /* Process is gone, so flag the event as finished. */ | /* Process is gone, so flag the event as finished. */ | ||||
| if (event == NOTE_EXIT) { | if ((event & NOTE_EXIT) != 0) { | ||||
| kn->kn_flags |= EV_EOF | EV_ONESHOT; | kn->kn_flags |= EV_EOF | EV_ONESHOT; | ||||
| if (kn->kn_fflags & NOTE_EXIT) | if (kn->kn_fflags & NOTE_EXIT) | ||||
| kn->kn_data = pd->pd_xstat; | kn->kn_data = pd->pd_xstat; | ||||
| if (kn->kn_fflags == 0) | if (kn->kn_fflags == 0) | ||||
| kn->kn_flags |= EV_DROP; | kn->kn_flags |= EV_DROP; | ||||
| return (1); | return (1); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 259 Lines • Show Last 20 Lines | |||||
In procdesc_kqops_event() there is a test, if (event == NOTE_EXIT). Probably that needs to change to if (event & NOTE_EXIT).