Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed annoying message: @@@ Got a sigPipe signal: Did the child close its tty? #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 4 additions & 20 deletions procServ.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,10 @@ void writeInfoFile(const std::string& infofile);
void ttySetCharNoEcho(bool save);

// Signal handlers
static void OnSigPipe(int);
static void OnSigTerm(int);
static void OnSigHup(int);

// Flags used for communication between sig handler and main()
static volatile sig_atomic_t sigPipeSet;
static volatile sig_atomic_t sigTermSet;
static volatile sig_atomic_t sigHupSet;

Expand Down Expand Up @@ -476,24 +474,23 @@ int main(int argc,char * argv[])

PRINTF("Installing signal handlers\n");

// SIGPIPE, SIGTERM and SIGHUP will be handled in the main loop
// SIGTERM and SIGHUP will be handled in the main loop
// with the assistance of pselect. This means that we have them
// blocked outside of pselect call, but unblocked atomically
// within pselect. Each time pselect returns, we safely check if
// any of the signals were received.
// any of the signals were received. SIGPIPE will be ignored.

// Block the signals that we bill be handling in the main loop.
// Block the signals that we will be handling in the main loop.
// At the same time, retrieve the original signal mask before
// blocking, to be passed to pselect.
sigset_t sigset_block;
sigset_t sigset_pselect;
sigemptyset(&sigset_block);
sigaddset(&sigset_block, SIGPIPE);
sigaddset(&sigset_block, SIGTERM);
sigaddset(&sigset_block, SIGHUP);
sigprocmask(SIG_BLOCK, &sigset_block, &sigset_pselect);

sig.sa_handler = &OnSigPipe; // sigaction() needed for Solaris
sig.sa_handler = SIG_IGN; // sigaction() needed for Solaris
sigaction(SIGPIPE, &sig, NULL);
sig.sa_handler = &OnSigTerm;
sigaction(SIGTERM, &sig, NULL);
Expand Down Expand Up @@ -598,8 +595,6 @@ int main(int argc,char * argv[])
// Run here until something makes it die
while ( ! shutdownServer )
{
const size_t BUFLEN = 100;
char buf[BUFLEN];
connectionItem * p;
fd_set fdset; // FD stuff for select()
int fd, nFd;
Expand All @@ -625,12 +620,6 @@ int main(int argc,char * argv[])

// Handle signals for which signal handlers were called while in pselect.

if (sigPipeSet) {
sigPipeSet = 0;
sprintf( buf, "@@@ Got a sigPipe signal: Did the child close its tty?" NL);
SendToAll( buf, strlen(buf), NULL );
}

if (sigTermSet) {
sigTermSet = 0;
PRINTF("SigTerm received\n");
Expand Down Expand Up @@ -848,11 +837,6 @@ void DeleteConnection(connectionItem *ci)
assert(connectionNo>=0);
}

static void OnSigPipe(int)
{
sigPipeSet = 1;
}

static void OnSigTerm(int)
{
sigTermSet = 1;
Expand Down