|
From: <sv...@va...> - 2009-05-21 23:59:41
|
Author: njn
Date: 2009-05-22 00:59:34 +0100 (Fri, 22 May 2009)
New Revision: 10087
Log:
Merge r10085, r10086 (post-fork handling) from the DARWIN branch.
Modified:
trunk/coregrind/m_syswrap/syswrap-generic.c
Modified: trunk/coregrind/m_syswrap/syswrap-generic.c
===================================================================
--- trunk/coregrind/m_syswrap/syswrap-generic.c 2009-05-21 23:58:47 UTC (rev 10086)
+++ trunk/coregrind/m_syswrap/syswrap-generic.c 2009-05-21 23:59:34 UTC (rev 10087)
@@ -2780,7 +2780,8 @@
// ignore the various args it gets, and so it looks arch-neutral. Hmm.
PRE(sys_fork)
{
- UWord result;
+ Bool is_child;
+ Int child_pid;
vki_sigset_t mask;
PRINT("sys_fork ( )");
@@ -2795,12 +2796,13 @@
if (!SUCCESS) return;
- result = RES;
+ // RES is 0 for child, non-0 (the child's PID) for parent.
+ is_child = ( RES == 0 ? True : False );
+ child_pid = ( is_child ? -1 : RES );
VG_(do_atfork_pre)(tid);
- if (SUCCESS && RES == 0) {
- /* child */
+ if (is_child) {
VG_(do_atfork_child)(tid);
/* restore signal mask */
@@ -2812,13 +2814,11 @@
duly stops writing any further logging output. */
if (!VG_(logging_to_socket) && VG_(clo_child_silent_after_fork))
VG_(clo_log_fd) = -1;
- }
- else
- if (SUCCESS && RES > 0) {
- /* parent */
+
+ } else {
VG_(do_atfork_parent)(tid);
- PRINT(" fork: process %d created child %ld\n", VG_(getpid)(), RES);
+ PRINT(" fork: process %d created child %d\n", VG_(getpid)(), child_pid);
/* restore signal mask */
VG_(sigprocmask)(VKI_SIG_SETMASK, &fork_saved_mask, NULL);
|