You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stdcxx.apache.org by fa...@apache.org on 2007/10/31 16:18:17 UTC

svn commit: r590711 - /incubator/stdcxx/branches/4.2.x/tests/src/process.cpp

Author: faridz
Date: Wed Oct 31 08:18:16 2007
New Revision: 590711

URL: http://svn.apache.org/viewvc?rev=590711&view=rev
Log:
2007-10-31 Travis Vitek <vi...@roguewave.com>

	STDCXX-625
	* process.cpp (sig_handler): Don't re-register for signal from
	within signal handler to avoid stack overflow on HP-UX and AIX.
	(rw_waitpid): Set and restore signal handler inside loop so we
	can avoid using the signal handler to do it.

Modified:
    incubator/stdcxx/branches/4.2.x/tests/src/process.cpp

Modified: incubator/stdcxx/branches/4.2.x/tests/src/process.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.x/tests/src/process.cpp?rev=590711&r1=590710&r2=590711&view=diff
==============================================================================
--- incubator/stdcxx/branches/4.2.x/tests/src/process.cpp (original)
+++ incubator/stdcxx/branches/4.2.x/tests/src/process.cpp Wed Oct 31 08:18:16 2007
@@ -524,8 +524,8 @@
 static void
 sig_handler (int)
 {
-    // restore the signal
-    signal (SIGCHLD, sig_handler);
+    // do not re-register for signal here. it causes
+    // a stack overflow problem on HP-UX and AIX.
 }
 
 }
@@ -545,12 +545,16 @@
 
     if (0 < timeout && 0 == ret) {
         // process still active, wait
-        sig_handler_t* old_handler = signal (SIGCHLD, sig_handler);
 
         unsigned utimeout = unsigned (timeout);
 
         do {
+            sig_handler_t* old_handler = signal (SIGCHLD, sig_handler);
+
             utimeout = sleep (utimeout);
+
+            signal (SIGCHLD, old_handler);
+
             if (utimeout) {
                 // possible that the child has exited
                 ret = waitpid (pid, &status, WNOHANG);
@@ -575,8 +579,6 @@
             }
         }
         while (false);
-
-        signal (SIGCHLD, old_handler);
     }
 
     if (ret == pid) {