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
This commit is contained in:
Mike Barcroft 2002-06-01 18:37:46 +00:00
parent 136956ed12
commit 6ee093fb8f
4 changed files with 22 additions and 1 deletions

View File

@ -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 @@ wait1(td, uap, compat)
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) {

View File

@ -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;

View File

@ -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

View File

@ -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