mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 12:36:58 +00:00
Keep dead console from killing asterisk (bu #3331)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4798 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
23
asterisk.c
23
asterisk.c
@@ -1587,6 +1587,7 @@ int main(int argc, char *argv[])
|
|||||||
int num;
|
int num;
|
||||||
char *buf;
|
char *buf;
|
||||||
char *runuser=NULL, *rungroup=NULL;
|
char *runuser=NULL, *rungroup=NULL;
|
||||||
|
struct pollfd silly_macos[1];
|
||||||
|
|
||||||
/* Remember original args for restart */
|
/* Remember original args for restart */
|
||||||
if (argc > sizeof(_argv) / sizeof(_argv[0]) - 1) {
|
if (argc > sizeof(_argv) / sizeof(_argv[0]) - 1) {
|
||||||
@@ -1917,16 +1918,24 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
consolehandler((char *)buf);
|
consolehandler((char *)buf);
|
||||||
} else {
|
} else {
|
||||||
if (option_remote)
|
if (write(STDOUT_FILENO, "\nUse EXIT or QUIT to exit the asterisk console\n",
|
||||||
ast_cli(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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user