ConsumerExport.cc File Reference

#include "ConsumerExport.h"
#include <sys/wait.h>
#include <signal.h>
#include <unistd.h>
#include <cstdlib>
#include <string>
#include "TConsumerInfo.h"
#include "ServerProtocol.h"

Go to the source code of this file.

Functions

static void sigChildHandler (int sig)
static void pipeBroken (int sig)

Variables

const int serverStartFailCode = 20
static pid_t serverPid = 0
static bool serverStartFailed = false
static bool brokenPipe = false

Function Documentation

static void pipeBroken ( int  sig  )  [static]

Definition at line 100 of file ConsumerExport.cc.

References brokenPipe.

Referenced by ConsumerExport::ConsumerExport().

00101   {    
00102     const string myName = string("ConsumerExport#pipeBroken");
00103     cerr << myName << ": Got signal SIGPIPE (" << sig << ")."  << endl;  
00104     brokenPipe = true;
00105   } 

static void sigChildHandler ( int  sig  )  [static]

Definition at line 50 of file ConsumerExport.cc.

References serverPid, serverStartFailCode, and serverStartFailed.

Referenced by ConsumerExport::ConsumerExport().

00051   {
00052     const string myName = string("ConsumerExport#sigChildHandler");
00053     bool locDebug = false;
00054 #ifdef CONSUMEREXPORT_DEBUG
00055     locDebug = true;
00056 #endif
00057 
00058     if (locDebug) {
00059       cout << myName << ": Got signal ";
00060       if (sig == SIGCHLD) cout << "SIGCHLD (";
00061       cout << "= " << sig << ")." << endl;
00062     }
00063     pid_t waitRes;
00064     int status;
00065     waitRes = waitpid(serverPid, &status, WNOHANG);         
00066     if (locDebug)  cout << myName << ": Returned process: pid = " 
00067                         << waitRes << "." << endl;
00068     if (waitRes == serverPid) {
00069       // The returned process was the display server. 
00070       if (WIFEXITED(status)) {
00071         if (locDebug) cout << myName << ": Normal termination, exit status = " 
00072                            << WEXITSTATUS(status) << endl;
00073         if (WEXITSTATUS(status) == serverStartFailCode) {
00074           cerr << myName <<  ": Failed to start the Server. The forked\n"
00075                << "child process could not find the Server program."
00076                << endl;
00077           serverStartFailed = true;
00078         }
00079       } 
00080       else {
00081         if (WIFSIGNALED(status)) {
00082           cerr << myName << ": Abnormal termination, signal number = "
00083                << WTERMSIG(status) << 
00084 #ifdef WCOREDUMP
00085           ( WCOREDUMP(status) ? ". Core file generated." : "." );
00086 #else
00087           "."; 
00088 #endif
00089           cout << endl;
00090         }
00091       }
00092     }
00093     else {
00094       if (locDebug) cout << "Process other than the server returned." << endl;
00095     }
00096  
00097     return;
00098   }


Variable Documentation

bool brokenPipe = false [static]
pid_t serverPid = 0 [static]

Definition at line 44 of file ConsumerExport.cc.

Referenced by sigChildHandler(), and ConsumerExport::startServer().

const int serverStartFailCode = 20

Definition at line 43 of file ConsumerExport.cc.

Referenced by sigChildHandler(), and ConsumerExport::startServer().

bool serverStartFailed = false [static]

Generated on 15 Jul 2018 for loon by  doxygen 1.6.1