Differences between current version and predecessor to the previous major change of SIGCHLD.
Other diffs: Previous Revision, Previous Author, or view the Annotated Edit History
Newer page: | version 4 | Last edited on Wednesday, February 22, 2006 11:39:30 am | by KenHylton | |
Older page: | version 3 | Last edited on Tuesday, May 31, 2005 4:23:04 pm | by JohnMcPherson | Revert |
@@ -50,4 +50,36 @@
continue in parent....
</verbatim>
----
If you don't do either of wait() or set the signal handler, then the child will remain a ZombieProcess.
+
+--------------------------------------------------------
+Interesting note for RedHat enterprise Linux 4 and Fedora 4 users, found with both gcc 3.4.4 (RHEL4) and gcc 4.0.0 (Fedora4): another issue found when ignoring SIGCHLD is that the system() function will not work in your child code. If you ignore SIGCHLD, all of your calls to system() will return -1, indicating that they fail, even though they are actually completed OK. Using this test code:
+
+<verbatim>
+ pid_t nPid;
+ signal( SIGCHLD, SIG_IGN );
+ if( 0 == ( nPid = fork() ) )
+ {
+ ofstream ofstrTestFile;
+ ofstrTestFile.open( "TestFile.txt", ofstream::out | ofstream::trunc );
+ ofstrTestFile << "Testing...1...2...3...4..." << ends;
+ ofstrTestFile.close();
+ string strTemp;
+ strTemp = "mv TestFile.txt TestFile.mv";
+ int nTemp;
+ nTemp = system( strTemp.c_str() );
+ if ( 0 != nTemp )
+ {
+ cout << "It failed nTemp <" << nTemp << ">" << endl << endl;
+ }
+ else
+ {
+ cout << "It worked nTemp <" << nTemp << ">" << endl << endl;
+ }
+ return ( true );
+ }
+</verbatim>
+
+It will fail and return -1. If you remove signal( SIGCHLD, SIG_IGN ); the code will work properly. In either case, the mv command is actually performed successfully.
+
+This used to work with the signal call in older versions of Redhat and older compilers.