diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-01-15 21:44:48 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-01-15 21:44:48 +0000 |
commit | a3f6a20e1b1ef2fe3ccfe32e182876a3446d2989 (patch) | |
tree | 26cd07db26242b040887d10730f6c56cf508628b /main/asterisk.c | |
parent | 1e1bd71bf7b20e94ae600eaaf5931884afee18e3 (diff) |
Merged revisions 240499-240500 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
........
r240499 | tilghman | 2010-01-15 15:40:14 -0600 (Fri, 15 Jan 2010) | 9 lines
The previous attempt at using a pipe to guarantee astcanary shutdown did not work.
We're revisiting the previous patch, albeit with a method that overcomes the
prior criticism that it was not POSIX-compliant.
(closes issue #16602)
Reported by: frawd
Patches:
20100114__issue16602.diff.txt uploaded by tilghman (license 14)
Tested by: frawd
........
r240500 | tilghman | 2010-01-15 15:42:36 -0600 (Fri, 15 Jan 2010) | 2 lines
Oops, missed an include
........
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.2@240503 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/asterisk.c')
-rw-r--r-- | main/asterisk.c | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/main/asterisk.c b/main/asterisk.c index 83b851ebb..95f2569bd 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -275,7 +275,6 @@ static int restartnow; static pthread_t consolethread = AST_PTHREADT_NULL; static int canary_pid = 0; static char canary_filename[128]; -static int canary_pipe = -1; static char randompool[256]; @@ -3484,15 +3483,6 @@ int main(int argc, char *argv[]) /* Spawning of astcanary must happen AFTER the call to daemon(3) */ if (isroot && ast_opt_high_priority) { - int cpipe[2]; - - /* PIPE signal ensures that astcanary dies when Asterisk dies */ - if (pipe(cpipe)) { - fprintf(stderr, "Unable to open pipe for canary process: %s\n", strerror(errno)); - exit(1); - } - canary_pipe = cpipe[0]; - snprintf(canary_filename, sizeof(canary_filename), "%s/alt.asterisk.canary.tweet.tweet.tweet", ast_config_AST_RUN_DIR); /* Don't let the canary child kill Asterisk, if it dies immediately */ @@ -3500,18 +3490,17 @@ int main(int argc, char *argv[]) canary_pid = fork(); if (canary_pid == 0) { - char canary_binary[128], *lastslash; + char canary_binary[128], *lastslash, ppid[12]; /* Reset signal handler */ signal(SIGCHLD, SIG_DFL); signal(SIGPIPE, SIG_DFL); - dup2(cpipe[1], 0); - close(cpipe[1]); ast_close_fds_above_n(0); ast_set_priority(0); + snprintf(ppid, sizeof(ppid), "%d", (int) getpid()); - execlp("astcanary", "astcanary", canary_filename, (char *)NULL); + execlp("astcanary", "astcanary", canary_filename, ppid, (char *)NULL); /* If not found, try the same path as used to execute asterisk */ ast_copy_string(canary_binary, argv[0], sizeof(canary_binary)); @@ -3524,12 +3513,11 @@ int main(int argc, char *argv[]) _exit(1); } else if (canary_pid > 0) { pthread_t dont_care; - close(cpipe[1]); ast_pthread_create_detached(&dont_care, NULL, canary_thread, NULL); } /* Kill the canary when we exit */ - atexit(canary_exit); + ast_register_atexit(canary_exit); } if (ast_event_init()) { |