commit 236691fb12e57db0a7ccd255c8027b6dfa1bd006 Author: mike Date: Sat Jun 1 18:37:46 2002 +0000 Add POSIX.1-2001 WCONTINUED option for waitpid(2). A proc flag (P_CONTINUED) is set when a stopped process receives a SIGCONT and cleared after it has notified a parent process that has requested notification via waitpid(2) with WCONTINUED specified in its options operand. The status value can be checked with the new WIFCONTINUED() macro. Reviewed by: jake diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 9d1349a..8fb715a 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)kern_exit.c 8.7 (Berkeley) 2/12/94 - * $FreeBSD: src/sys/kern/kern_exit.c,v 1.165 2002/05/23 04:12:28 jhb Exp $ + * $FreeBSD: src/sys/kern/kern_exit.c,v 1.166 2002/06/01 18:37:45 mike Exp $ */ #include "opt_compat.h" @@ -505,7 +505,7 @@ wait1(td, uap, compat) uap->pid = -q->p_pgid; PROC_UNLOCK(q); } - if (uap->options &~ (WUNTRACED|WNOHANG|WLINUXCLONE)) + if (uap->options &~ (WUNTRACED|WNOHANG|WCONTINUED|WLINUXCLONE)) return (EINVAL); mtx_lock(&Giant); loop: @@ -688,6 +688,22 @@ loop: mtx_unlock(&Giant); return (error); } + if (uap->options & WCONTINUED && (p->p_flag & P_CONTINUED)) { + sx_xunlock(&proctree_lock); + td->td_retval[0] = p->p_pid; + p->p_flag &= ~P_CONTINUED; + PROC_UNLOCK(p); + + if (uap->status) { + status = SIGCONT; + error = copyout((caddr_t)&status, + (caddr_t)uap->status, sizeof(status)); + } else + error = 0; + + mtx_unlock(&Giant); + return (error); + } PROC_UNLOCK(p); } if (nfound == 0) { diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index b711171..0177748 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)kern_sig.c 8.7 (Berkeley) 4/18/94 - * $FreeBSD: src/sys/kern/kern_sig.c,v 1.166 2002/05/29 23:44:31 julian Exp $ + * $FreeBSD: src/sys/kern/kern_sig.c,v 1.167 2002/06/01 18:37:45 mike Exp $ */ #include "opt_compat.h" @@ -1436,6 +1436,8 @@ psignal(p, sig) } } } else { + p->p_flag |= P_CONTINUED; + wakeup((caddr_t)p->p_pptr); if (td->td_wchan == NULL) goto run; p->p_stat = SSLEEP; diff --git a/sys/sys/proc.h b/sys/sys/proc.h index d8cafac..0b4c538 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)proc.h 8.15 (Berkeley) 5/19/95 - * $FreeBSD: src/sys/sys/proc.h,v 1.221 2002/05/19 00:14:50 jhb Exp $ + * $FreeBSD: src/sys/sys/proc.h,v 1.222 2002/06/01 18:37:46 mike Exp $ */ #ifndef _SYS_PROC_H_ @@ -486,6 +486,7 @@ struct proc { #define P_WEXIT 0x02000 /* Working on exiting. */ #define P_EXEC 0x04000 /* Process called exec. */ #define P_KSES 0x08000 /* Process is using KSEs. */ +#define P_CONTINUED 0x10000 /* Proc has continued from a stopped state. */ /* Should be moved to machine-dependent areas. */ #define P_UNUSED100000 0x100000 diff --git a/sys/sys/wait.h b/sys/sys/wait.h index 8dc0647..76a6607 100644 --- a/sys/sys/wait.h +++ b/sys/sys/wait.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)wait.h 8.2 (Berkeley) 7/10/94 - * $FreeBSD: src/sys/sys/wait.h,v 1.13 2002/05/27 00:55:17 mike Exp $ + * $FreeBSD: src/sys/sys/wait.h,v 1.14 2002/06/01 18:37:46 mike Exp $ */ #ifndef _SYS_WAIT_H_ @@ -61,6 +61,7 @@ #define WTERMSIG(x) (_WSTATUS(x)) #define WIFEXITED(x) (_WSTATUS(x) == 0) #define WEXITSTATUS(x) (_W_INT(x) >> 8) +#define WIFCONTINUED(x) (x == 0x13) /* 0x13 == SIGCONT */ #ifndef _POSIX_SOURCE #define WCOREDUMP(x) (_W_INT(x) & WCOREFLAG) @@ -79,6 +80,7 @@ */ #define WNOHANG 1 /* don't hang in wait */ #define WUNTRACED 2 /* tell about stopped, untraced children */ +#define WCONTINUED 4 /* Report a job control continued process. */ #define WLINUXCLONE 0x80000000 /* wait for kthread spawned from linux_clone */ #ifndef _POSIX_SOURCE