From: Roland McGrath Date: Wed, 1 Sep 2004 19:39:46 +0000 (+0000) Subject: 2004-09-01 Roland McGrath X-Git-Tag: v4.5.18~522 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c74c0b732b66139d59e616210718950f2853f3aa;p=strace 2004-09-01 Roland McGrath * process.c (internal_wait): Take second arg giving index of flags argument. * defs.h: Update prototype. * syscall.c (internal_syscall): Update caller. Also use internal_wait for SYS_waitid. * process.c (sys_waitid): Define for [LINUX] as well. Don't tweak TCB_SUSPENDED--internal_wait does that. (waitid_types): Conditionalize use of nonstandard P_* macros. --- diff --git a/defs.h b/defs.h index ca6240a0..f4e12a0e 100644 --- a/defs.h +++ b/defs.h @@ -466,7 +466,7 @@ extern int internal_clone P((struct tcb *)); #endif extern int internal_fork P((struct tcb *)); extern int internal_exec P((struct tcb *)); -extern int internal_wait P((struct tcb *)); +extern int internal_wait P((struct tcb *, int)); extern int internal_exit P((struct tcb *)); extern struct ioctlent *ioctl_lookup P((long)); diff --git a/process.c b/process.c index ac28e4e0..00116704 100644 --- a/process.c +++ b/process.c @@ -1868,8 +1868,9 @@ int bitness; } int -internal_wait(tcp) +internal_wait(tcp, flagarg) struct tcb *tcp; +int flagarg; { int got_kids; @@ -1895,7 +1896,7 @@ struct tcb *tcp; /* ??? WTA: fix bug with hanging children */ - if (!(tcp->u_arg[2] & WNOHANG)) { + if (!(tcp->u_arg[flagarg] & WNOHANG)) { /* * There are traced children. We'll make the parent * block to avoid a false ECHILD error due to our @@ -1936,7 +1937,7 @@ struct tcb *tcp; } } if (exiting(tcp) && tcp->u_error == ECHILD && got_kids) { - if (tcp->u_arg[2] & WNOHANG) { + if (tcp->u_arg[flagarg] & WNOHANG) { /* We must force a fake result of 0 instead of the ECHILD error. */ extern int force_result(); @@ -2012,16 +2013,26 @@ struct tcb *tcp; } #endif -#ifdef SVR4 +#if defined SVR4 || defined LINUX static struct xlat waitid_types[] = { { P_PID, "P_PID" }, +#ifdef P_PPID { P_PPID, "P_PPID" }, +#endif { P_PGID, "P_PGID" }, +#ifdef P_SID { P_SID, "P_SID" }, +#endif +#ifdef P_CID { P_CID, "P_CID" }, +#endif +#ifdef P_UID { P_UID, "P_UID" }, +#endif +#ifdef P_GID { P_GID, "P_GID" }, +#endif { P_ALL, "P_ALL" }, #ifdef P_LWPID { P_LWPID, "P_LWPID" }, @@ -2039,11 +2050,6 @@ struct tcb *tcp; if (entering(tcp)) { printxval(waitid_types, tcp->u_arg[0], "P_???"); tprintf(", %ld, ", tcp->u_arg[1]); - if (tcp->nchildren > 0) { - /* There are traced children */ - tcp->flags |= TCB_SUSPENDED; - tcp->waitpid = tcp->u_arg[0]; - } } else { /* siginfo */ @@ -2064,7 +2070,7 @@ struct tcb *tcp; return 0; } -#endif /* SVR4 */ +#endif /* SVR4 or LINUX */ int sys_alarm(tcp) diff --git a/syscall.c b/syscall.c index 666b9be4..31589e45 100644 --- a/syscall.c +++ b/syscall.c @@ -698,8 +698,13 @@ struct tcb *tcp; #ifdef SYS_waitsys case SYS_waitsys: #endif - internal_wait(tcp); + internal_wait(tcp, 2); break; +#ifdef SYS_waitid + case SYS_waitid: + internal_wait(tcp, 3); + break; +#endif #ifdef SYS_exit case SYS_exit: