Commit fea8fc06 authored by whitlocb's avatar whitlocb

Change RemoteProcess to install the old signal handler once we're done starting a process.

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@26690 18c085ea-50e0-402c-830e-de6fd14e8384
parent 1d9daaef
......@@ -127,6 +127,8 @@ using std::map;
static map<int, bool> childDied=std::map<int, bool>();
#if !defined(_WIN32)
static void (*old_signal_handler)(int) = SIG_DFL;
// ****************************************************************************
// Function: catch_dead_child
//
......@@ -1196,8 +1198,11 @@ RemoteProcess::Open(const MachineProfile &profile, int numRead, int numWrite,
FinishMakingConnection(numRead, numWrite);
#if !defined(_WIN32)
// Stop watching for dead children
signal(SIGCHLD, SIG_DFL);
// Install the old signal handler
if(old_signal_handler != SIG_ERR)
signal(SIGCHLD, old_signal_handler);
else
signal(SIGCHLD, SIG_DFL);
#endif
debug5 << mName << "Returning true" << endl;
......@@ -2305,18 +2310,23 @@ RemoteProcess::LaunchRemote(const std::string &host, const std::string &password
int ptyFileDescriptor;
if (!disablePTY)
{
// Get the old signal handler.
old_signal_handler = signal(SIGCHLD, SIG_DFL);
if(old_signal_handler != SIG_ERR)
signal(SIGCHLD, old_signal_handler);
// we will tell pty_fork to set up the signal handler for us, because
// this call must come after the grantpt call inside pty_fork()
remoteProgramPid = pty_fork(ptyFileDescriptor, catch_dead_child);
}
else
{
signal(SIGCHLD, catch_dead_child);
old_signal_handler = signal(SIGCHLD, catch_dead_child);
remoteProgramPid = fork();
}
#else
debug5 << mName << "Starting child process using fork" << endl;
signal(SIGCHLD, catch_dead_child);
old_signal_handler = signal(SIGCHLD, catch_dead_child);
remoteProgramPid = fork();
#endif
switch (remoteProgramPid)
......@@ -2484,6 +2494,10 @@ RemoteProcess::KillProcess()
// Kill the process
kill(remoteProgramPid, SIGTERM);
// Reinstall the old signal handler.
if(old_signal_handler != SIG_ERR)
signal(SIGCHLD, old_signal_handler);
#endif
remoteProgramPid = -1;
}
......@@ -2586,7 +2600,7 @@ RemoteProcess::LaunchLocal(const stringVector &args)
remoteProgramPid = _spawnvp(_P_NOWAIT, argv[0], argv);
#else
// Watch for a remote process who died
signal(SIGCHLD, catch_dead_child);
old_signal_handler = signal(SIGCHLD, catch_dead_child);
debug5 << mName << "Starting child process using fork" << endl;
int rv, i;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment