Fix sigchld handling (bug #2245)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3633 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Spencer
2004-08-22 18:33:19 +00:00
parent f2dcfca9c4
commit 60707a4172

View File

@@ -170,6 +170,12 @@ static int fdprint(int fd, const char *s)
return write(fd, s, strlen(s) + 1); return write(fd, s, strlen(s) + 1);
} }
/* NULL handler so we can collect the child exit status */
static void null_sig_handler(int signal)
{
}
int ast_safe_system(const char *s) int ast_safe_system(const char *s)
{ {
/* XXX This function needs some optimization work XXX */ /* XXX This function needs some optimization work XXX */
@@ -178,6 +184,7 @@ int ast_safe_system(const char *s)
int res; int res;
struct rusage rusage; struct rusage rusage;
int status; int status;
void (*prev_handler) = signal(SIGCHLD, null_sig_handler);
pid = fork(); pid = fork();
if (pid == 0) { if (pid == 0) {
/* Close file descriptors and launch system command */ /* Close file descriptors and launch system command */
@@ -204,6 +211,7 @@ int ast_safe_system(const char *s)
ast_log(LOG_WARNING, "Fork failed: %s\n", strerror(errno)); ast_log(LOG_WARNING, "Fork failed: %s\n", strerror(errno));
res = -1; res = -1;
} }
signal(SIGCHLD, prev_handler);
return res; return res;
} }