Skip to content

Commit

Permalink
Handle SIGCHLD and reap zombie processes
Browse files Browse the repository at this point in the history
  • Loading branch information
makomk committed Jan 1, 2012
1 parent d30b81b commit 578e6df
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,23 @@ Q_IMPORT_PLUGIN(qtwcodecs)
Q_IMPORT_PLUGIN(qkrcodecs)
#endif

#ifndef WIN32
#include <sys/wait.h>
#endif

using namespace std;
using namespace boost;

CWallet* pwalletMain;

#ifndef WIN32
void HandleSIGCHLD(int)
{
int status;
while(waitpid(-1, &status, WNOHANG) > 0);
}
#endif

//////////////////////////////////////////////////////////////////////////////
//
// Shutdown
Expand Down Expand Up @@ -143,6 +155,10 @@ bool AppInit2(int argc, char* argv[])
sigaction(SIGTERM, &sa, NULL);
sigaction(SIGINT, &sa, NULL);
sigaction(SIGHUP, &sa, NULL);

// Reap zombie child processes
sa.sa_handler = HandleSIGCHLD;
sigaction(SIGCHLD, &sa, NULL);
#endif

//
Expand Down

0 comments on commit 578e6df

Please sign in to comment.