aboutsummaryrefslogtreecommitdiffstats
path: root/main/asterisk.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-12-11 23:48:48 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-12-11 23:48:48 +0000
commitd73af94fec9875e6aff077dcf819cfd1e473fe50 (patch)
tree19a9a510c7926c0759c28f4c2b601e1b6c75c5d1 /main/asterisk.c
parentc358989657e11d3074da3071e3e4607d3735bdec (diff)
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: http://svn.digium.com/svn/asterisk/branches/1.6.1@163386 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/asterisk.c')
-rw-r--r--main/asterisk.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/main/asterisk.c b/main/asterisk.c
index e85479b15..fff193a2e 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -1451,6 +1451,11 @@ static void __quit_handler(int num)
* 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)
{
const char *c;
@@ -2443,6 +2448,11 @@ static void ast_remotecontrol(char *data)
char *ebuf;
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) {
ast_log(LOG_ERROR, "read() failed: %s\n", strerror(errno));
return;
@@ -2453,6 +2463,9 @@ static void ast_remotecontrol(char *data)
sprintf(tmp, "%s%s", prefix, data);
if (write(ast_consock, tmp, strlen(tmp) + 1) < 0) {
ast_log(LOG_ERROR, "write() failed: %s\n", strerror(errno));
+ if (sig_flags.need_quit == 1) {
+ return;
+ }
}
}
stringp = buf;
@@ -2499,6 +2512,10 @@ static void ast_remotecontrol(char *data)
char buffer[512] = "", *curline = buffer, *nextline;
int not_written = 1;
+ if (sig_flags.need_quit == 1) {
+ break;
+ }
+
if (read(ast_consock, buffer, sizeof(buffer) - 1) <= 0) {
break;
}
@@ -2530,6 +2547,10 @@ static void ast_remotecontrol(char *data)
for (;;) {
ebuf = (char *)el_gets(el, &num);
+ if (sig_flags.need_quit == 1) {
+ break;
+ }
+
if (!ebuf && write(1, "", 1) < 0)
break;