]> granicus.if.org Git - strace/commitdiff
2008-06-27 Jan Kratochvil <jan.kratochvil@redhat.com>
authorRoland McGrath <roland@redhat.com>
Fri, 18 Jul 2008 01:09:44 +0000 (01:09 +0000)
committerRoland McGrath <roland@redhat.com>
Fri, 18 Jul 2008 01:09:44 +0000 (01:09 +0000)
* util.c (CLONE_VFORK): Define if not defined already.
(setbpt): Clear CLONE_VFORK for SYS_clone and SYS_clone2.
Reported by Vitaly Mayatskikh.

util.c

diff --git a/util.c b/util.c
index fc54f1ad97a772b838e6f4149c0e50d4a65c6335..7b33ddcc1d08c7c0f1039ae0a0de52f67ca9b9aa 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1281,6 +1281,9 @@ struct tcb *tcp;
 #ifndef CLONE_PTRACE
 # define CLONE_PTRACE    0x00002000
 #endif
+#ifndef CLONE_VFORK
+# define CLONE_VFORK     0x00004000
+#endif
 #ifndef CLONE_STOPPED
 # define CLONE_STOPPED   0x02000000
 #endif
@@ -1524,12 +1527,17 @@ struct tcb *tcp;
 #ifdef SYS_clone2
        case SYS_clone2:
 #endif
-               if ((tcp->u_arg[arg0_index] & CLONE_PTRACE) == 0
-                   && (arg_setup (tcp, &state) < 0
-                       || set_arg0 (tcp, &state,
-                                    tcp->u_arg[arg0_index] | CLONE_PTRACE) < 0
-                       || arg_finish_change (tcp, &state) < 0))
-                       return -1;
+               /* ia64 calls directly `clone (CLONE_VFORK)' contrary to
+                  x86 SYS_vfork above.  Even on x86 we turn the vfork
+                  semantics into plain fork - each application must not
+                  depend on the vfork specifics according to POSIX.  We
+                  would hang waiting for the parent resume otherwise.  */
+               if ((arg_setup (tcp, &state) < 0
+                   || set_arg0 (tcp, &state,
+                                (tcp->u_arg[arg0_index] | CLONE_PTRACE)
+                                & ~CLONE_VFORK) < 0
+                   || arg_finish_change (tcp, &state) < 0))
+                   return -1;
                tcp->flags |= TCB_BPTSET;
                tcp->inst[0] = tcp->u_arg[arg0_index];
                tcp->inst[1] = tcp->u_arg[arg1_index];