]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
Bug 811: child process should call _exit() instead of exit()
authorAidan Van Dyk <aidan@ifax.com>
Wed, 14 Mar 2007 18:31:52 +0000 (18:31 +0000)
committerAidan Van Dyk <aidan@ifax.com>
Wed, 14 Mar 2007 18:31:52 +0000 (18:31 +0000)
  Child processes call exit() at several places in hylafax, e.g. in
  FaxServer::notifyPageSent() in FaxSend.c++. This is dangerous, see
  http://www.erlenstar.demon.co.uk/unix/faq_2.html#SEC6
  I managed to get exit() to hang in notifyPageSent() when writing my own
  replacement for faxsend, although I can't tell you how to reproduce it in a
  regular faxsend.

CHANGES
faxd/Class1Recv.c++
faxd/CopyQuality.c++
faxd/FaxRecv.c++
faxd/faxGettyApp.c++
faxd/faxSendApp.c++

diff --git a/CHANGES b/CHANGES
index a1ef623da82108eafaea641be5d7d121b3aaba60..495cfc87a83feb155a9fa2145dff2b0e6c4b0fa4 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,7 @@
 
 Changelog since HylaFAX 4.3.3
 
+* Bug 811: children should exit with _exit() (12 Mar 2007)
 * Handle instances where ECM is negotiated but the sender
   transmits non-ECM data and signalling (12 Mar 2007)
 * Handle MPS/EOP/EOM/CRP when expecting DCS, i.e. after RTN
index 162127313b7a9f6254ee362e2ad241a8e2d72eed..be7a51452890d5819cd38098790f8fd1d2e95062 100644 (file)
@@ -830,7 +830,7 @@ Class1Modem::recvPage(TIFF* tif, u_int& ppm, fxStr& emsg, const fxStr& id)
                                        }
                                    } while (!gotEOT && !recvdDCN && tbuf[0] != 0 && Sys::now()-rrstart < 60);
                                    Sys::read(fcfd[0], NULL, 1);
-                                   exit(0);
+                                   _exit(0);
                                default:        // parent
                                    Sys::close(fcfd[0]);
                                    TIFFWriteDirectory(tif);
@@ -1663,7 +1663,7 @@ Class1Modem::recvPageECMData(TIFF* tif, const Class2Params& params, fxStr& emsg)
                        } else tbuf[0] = 0;     // parent finished writeECMData
                    } while (!gotEOT && !recvdDCN && tbuf[0] != 0 && Sys::now()-rrstart < 60);
                    Sys::read(fcfd[0], NULL, 1);
-                   exit(0);
+                   _exit(0);
                default:        // parent
                    Sys::close(fcfd[0]);
                    writeECMData(tif, block, cc, params, seq);
index 3c1fec0c8bb00c57f907d3e98a418960c08f14c1..30f16e283a8ced0d7da532d4454a1abdbbe50ef3 100644 (file)
@@ -545,7 +545,7 @@ FaxModem::writeECMData(TIFF* tif, u_char* buf, u_int cc, const Class2Params& par
                                }
                                // write the line count to the pipe
                                Sys::write(counterFd[1], (const char*) &recvEOLCount, sizeof(recvEOLCount));
-                               exit(0);
+                               _exit(0);
                            default:    // parent
                                Sys::close(decoderFd[0]);
                                Sys::close(counterFd[1]);
index a90fd71359e9ded0342ea4ab9e1ce78597f50121..7ccc36f73102875392da0adfd66b301f90550f29 100644 (file)
@@ -75,7 +75,7 @@ FaxServer::recvFax(const CallID& callid, fxStr& emsg)
                    // NB: partially fill in info for notification call
                    notifyRecvBegun(info);
                    sleep(1);           // XXX give parent time
-                   exit(0);
+                   _exit(0);
                case -1:
                    logError("Can not fork for non-priority processing.");
                    notifyRecvBegun(info);
@@ -228,7 +228,7 @@ FaxServer::recvDocuments(TIFF* tif, FaxRecvInfo& info, FaxRecvInfoArray& docs, f
                if (pid > 0) (void) Sys::waitpid(pid);
                notifyDocumentRecvd(info);
                sleep(1);               // XXX give parent time
-               exit(0);
+               _exit(0);
            case -1:
                logError("Can not fork for non-priority logging.");
                notifyDocumentRecvd(info);
@@ -293,7 +293,7 @@ FaxServer::recvFaxPhaseD(TIFF* tif, FaxRecvInfo& info, u_int& ppm, fxStr& emsg)
                if (pid > 0) (void) Sys::waitpid(pid);
                notifyPageRecvd(tif, info, ppm);
                sleep(1);               // XXX give parent time
-               exit(0);
+               _exit(0);
            case -1:
                logError("Can not fork for non-priority logging.");
                notifyPageRecvd(tif, info, ppm);
index f636b7734505a7d197bbae1ea97e6c114ea746a8..a2880de7c22fa26e7a97ad0c5beafedff90e7a87 100644 (file)
@@ -363,7 +363,7 @@ faxGettyApp::answerPhone(AnswerType atype, CallType ctype, const CallID& callid,
                Sys::close(pipefd[1]);
                execl("/bin/sh", "sh", "-c", (const char*) cmd, (char*) NULL);
                sleep(1);
-               exit(1);
+               _exit(1);
            default:
                Sys::close(pipefd[1]);
                {
index 0333457829df43a7bdc0701a0531b6136dde5bb3..51f57eac22f2de5ac776a01e972269d72d94e9fd 100644 (file)
@@ -329,7 +329,7 @@ faxSendApp::notifyPageSent(FaxRequest& req, const char* filename)
        case 0:
            sendJobStatus(req.jobid, "d%s", (const char*) si.encode());
            sleep(1);           // XXX give parent time
-           exit(0);
+           _exit(0);
        case -1:
            logError("Can not fork for non-priority logging.");
            sendJobStatus(req.jobid, "d%s", (const char*) si.encode());