[Toxine-cvs] CVS: toxine/src main.c,1.43,1.44
Brought to you by:
f1rmb
From: Daniel Caujolle-B. <f1...@us...> - 2004-07-19 10:01:53
|
Update of /cvsroot/toxine/toxine/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31108 Modified Files: main.c Log Message: @@no need to fork() Index: main.c =================================================================== RCS file: /cvsroot/toxine/toxine/src/main.c,v retrieving revision 1.43 retrieving revision 1.44 diff -u -r1.43 -r1.44 --- main.c 19 Jul 2004 09:59:33 -0000 1.43 +++ main.c 19 Jul 2004 10:01:45 -0000 1.44 @@ -292,7 +292,10 @@ } -static int _real_main(int argc, char **argv) { +/* + * ... + */ +int main(int argc, char **argv) { int c = '?'; int option_index = 0; int interactive = 1; @@ -488,63 +491,3 @@ return last_error; } - -/* - * ... - */ -int main(int argc, char **argv) { - struct sigaction action; - int pid, status, ret; - - if(getuid() == 0) { - fprintf(stderr, "You cannot run this program as root.\n"); - exit(TOX_ERR_INTERNAL); - } - - signal(SIGHUP, SIG_IGN); - signal(SIGUSR1, SIG_IGN); - signal(SIGUSR2, SIG_IGN); - signal(SIGINT, SIG_IGN); - signal(SIGTERM, SIG_IGN); - signal(SIGQUIT, SIG_IGN); - signal(SIGALRM, SIG_IGN); - - action.sa_handler = toxine_signals_handler; - sigemptyset(&(action.sa_mask)); - action.sa_flags = 0; - if(sigaction(SIGSEGV, &action, NULL) != 0) - fprintf(stderr, "sigaction(SIGSEGV) failed: %s\n", strerror(errno)); - - pid = fork(); - switch(pid) { - case -1: - fprintf(stderr, "fork() failed: %s\n", strerror(errno)); - exit(TOX_ERR_FORK); - break; - - case 0: /* Child process */ - ret = _real_main(argc, argv); - exit(ret); - break; - - default: /* Parent */ - if(waitpid(pid, &status, 0) == -1) { - switch(errno) { - case EINTR: - case ENOMEM: - ret = TOX_ERR_FORK; - break; - default: - ret = TOX_ERR_SUCCESS; - break; - } - } - else { - ret = WEXITSTATUS(status); - break; - } - break; - } - - return ret; -} |