]> granicus.if.org Git - strace/commitdiff
2004-09-01 Roland McGrath <roland@redhat.com>
authorRoland McGrath <roland@redhat.com>
Wed, 1 Sep 2004 19:39:46 +0000 (19:39 +0000)
committerRoland McGrath <roland@redhat.com>
Wed, 1 Sep 2004 19:39:46 +0000 (19:39 +0000)
* 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.

defs.h
process.c
syscall.c

diff --git a/defs.h b/defs.h
index ca6240a014259048417d276df4aae8a5fed8ac02..f4e12a0e6a688783339a6e7edbb82c23dbc94373 100644 (file)
--- 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));
index ac28e4e0ddc8b65d835498dd14d6cf50434fff3b..0011670465044ef341beefe6f55dd038eb4a93c1 100644 (file)
--- 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)
index 666b9be41ac4caab9dc1da1b66cc3f9bb7b9ced0..31589e45be70ff1412d930b54aa26d87b847bbeb 100644 (file)
--- 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: