Changeset - 8013e49cd4bf
[Not reviewed]
0 1 0
Jan Kaluza - 14 years ago 2011-07-18 14:52:46
hanzz.k@gmail.com
waitpid in libpurple backend
1 file changed with 24 insertions and 7 deletions:
0 comments (0 inline, 0 general)
backends/libpurple/main.cpp
Show inline comments
 
@@ -21,6 +21,8 @@
 
#include "log4cxx/propertyconfigurator.h"
 
#include "log4cxx/helpers/properties.h"
 
#include "log4cxx/helpers/fileinputstream.h"
 
#include "sys/wait.h"
 
#include "sys/signal.h"
 

	
 
using namespace log4cxx;
 

	
 
@@ -1006,6 +1008,21 @@ static bool initPurple(Config &cfg) {
 
	return ret;
 
}
 

	
 
static void spectrum_sigchld_handler(int sig)
 
{
 
	int status;
 
	pid_t pid;
 

	
 
	do {
 
		pid = waitpid(-1, &status, WNOHANG);
 
	} while (pid != 0 && pid != (pid_t)-1);
 

	
 
	if ((pid == (pid_t) - 1) && (errno != ECHILD)) {
 
		char errmsg[BUFSIZ];
 
		snprintf(errmsg, BUFSIZ, "Warning: waitpid() returned %d", pid);
 
		perror(errmsg);
 
	}
 
}
 

	
 
int main(int argc, char **argv) {
 
	GError *error = NULL;
 
@@ -1040,13 +1057,13 @@ int main(int argc, char **argv) {
 
	}
 
	else {
 
#ifndef WIN32
 
// 		signal(SIGPIPE, SIG_IGN);
 
// 
 
// 		if (signal(SIGCHLD, spectrum_sigchld_handler) == SIG_ERR) {
 
// 			std::cout << "SIGCHLD handler can't be set\n";
 
// 			g_option_context_free(context);
 
// 			return -1;
 
// 		}
 
		signal(SIGPIPE, SIG_IGN);
 

	
 
		if (signal(SIGCHLD, spectrum_sigchld_handler) == SIG_ERR) {
 
			std::cout << "SIGCHLD handler can't be set\n";
 
			g_option_context_free(context);
 
			return -1;
 
		}
 
// 
 
// 		if (signal(SIGINT, spectrum_sigint_handler) == SIG_ERR) {
 
// 			std::cout << "SIGINT handler can't be set\n";
0 comments (0 inline, 0 general)