mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-07 10:28:32 +00:00
Merged revisions 163384 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ................ r163384 | tilghman | 2008-12-11 17:38:56 -0600 (Thu, 11 Dec 2008) | 16 lines Merged revisions 163383 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r163383 | tilghman | 2008-12-11 17:35:55 -0600 (Thu, 11 Dec 2008) | 9 lines When a Ctrl-C or Ctrl-D ends a remote console, on certain shells, the terminal is messed up. By intercepting those events with a signal handler in the remote console, we can avoid those issues. (closes issue #13464) Reported by: tzafrir Patches: 20081110__bug13464.diff.txt uploaded by Corydon76 (license 14) Tested by: blitzrage ........ ................ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.0@163385 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -1432,6 +1432,11 @@ static void __quit_handler(int num)
|
|||||||
* is going to exit */
|
* is going to exit */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void __remote_quit_handler(int num)
|
||||||
|
{
|
||||||
|
sig_flags.need_quit = 1;
|
||||||
|
}
|
||||||
|
|
||||||
static const char *fix_header(char *outbuf, int maxout, const char *s, char *cmp)
|
static const char *fix_header(char *outbuf, int maxout, const char *s, char *cmp)
|
||||||
{
|
{
|
||||||
const char *c;
|
const char *c;
|
||||||
@@ -2433,6 +2438,11 @@ static void ast_remotecontrol(char *data)
|
|||||||
char *ebuf;
|
char *ebuf;
|
||||||
int num = 0;
|
int num = 0;
|
||||||
|
|
||||||
|
memset(&sig_flags, 0, sizeof(sig_flags));
|
||||||
|
signal(SIGINT, __remote_quit_handler);
|
||||||
|
signal(SIGTERM, __remote_quit_handler);
|
||||||
|
signal(SIGHUP, __remote_quit_handler);
|
||||||
|
|
||||||
if (read(ast_consock, buf, sizeof(buf)) < 0) {
|
if (read(ast_consock, buf, sizeof(buf)) < 0) {
|
||||||
ast_log(LOG_ERROR, "read() failed: %s\n", strerror(errno));
|
ast_log(LOG_ERROR, "read() failed: %s\n", strerror(errno));
|
||||||
return;
|
return;
|
||||||
@@ -2440,6 +2450,9 @@ static void ast_remotecontrol(char *data)
|
|||||||
if (data) {
|
if (data) {
|
||||||
if (write(ast_consock, data, strlen(data) + 1) < 0) {
|
if (write(ast_consock, data, strlen(data) + 1) < 0) {
|
||||||
ast_log(LOG_ERROR, "write() failed: %s\n", strerror(errno));
|
ast_log(LOG_ERROR, "write() failed: %s\n", strerror(errno));
|
||||||
|
if (sig_flags.need_quit == 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stringp = buf;
|
stringp = buf;
|
||||||
@@ -2485,6 +2498,10 @@ static void ast_remotecontrol(char *data)
|
|||||||
char buf[512] = "", *curline = buf, *nextline;
|
char buf[512] = "", *curline = buf, *nextline;
|
||||||
int not_written = 1;
|
int not_written = 1;
|
||||||
|
|
||||||
|
if (sig_flags.need_quit == 1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (read(ast_consock, buf, sizeof(buf) - 1) <= 0) {
|
if (read(ast_consock, buf, sizeof(buf) - 1) <= 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -2516,6 +2533,10 @@ static void ast_remotecontrol(char *data)
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
ebuf = (char *)el_gets(el, &num);
|
ebuf = (char *)el_gets(el, &num);
|
||||||
|
|
||||||
|
if (sig_flags.need_quit == 1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (!ebuf && write(1, "", 1) < 0)
|
if (!ebuf && write(1, "", 1) < 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user