diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-01-15 08:53:28 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-01-15 08:53:28 +0000 |
commit | 51deaaf061bfaa8baf20b0d4508b80672a0f4e89 (patch) | |
tree | 1a470ad672608823173b34c40be96ae57af52cd8 /asterisk.c | |
parent | 57dadc793a5aa494ca0c494a7049d1754489739f (diff) |
Keep dead console from killing asterisk (bu #3331)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@4798 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'asterisk.c')
-rwxr-xr-x | asterisk.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/asterisk.c b/asterisk.c index 59e22cf38..a523b1fea 100755 --- a/asterisk.c +++ b/asterisk.c @@ -1587,6 +1587,7 @@ int main(int argc, char *argv[]) int num; char *buf; char *runuser=NULL, *rungroup=NULL; + struct pollfd silly_macos[1]; /* Remember original args for restart */ if (argc > sizeof(_argv) / sizeof(_argv[0]) - 1) { @@ -1917,16 +1918,24 @@ int main(int argc, char *argv[]) consolehandler((char *)buf); } else { - if (option_remote) - ast_cli(STDOUT_FILENO, "\nUse EXIT or QUIT to exit the asterisk console\n"); + if (write(STDOUT_FILENO, "\nUse EXIT or QUIT to exit the asterisk console\n", + strlen("\nUse EXIT or QUIT to exit the asterisk console\n")) < 0) { + /* Whoa, stdout disappeared from under us... Make /dev/null's */ + int fd; + fd = open("/dev/null", O_RDWR); + if (fd > -1) { + dup2(fd, STDOUT_FILENO); + dup2(fd, STDIN_FILENO); + } else + ast_log(LOG_WARNING, "Failed to open /dev/null to recover from dead console. Bad things will happen!\n"); + break; + } } } - } else { - struct pollfd silly_macos[1]; - /* Do nothing */ - for(;;) - poll(silly_macos,0, -1); } + /* Do nothing */ + for(;;) + poll(silly_macos,0, -1); return 0; } |