summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-04-28 19:07:01 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-04-28 19:07:01 -0700
commit4f616b1d8f97bf141d96dfdf225d09ef1172271d (patch)
tree16a1710aae8d5f1691404d145d3a08cba046158c
parent96a5d7816b280b11718d9c354d491cf87db1a70c (diff)
downloadtxr-4f616b1d8f97bf141d96dfdf225d09ef1172271d.tar.gz
txr-4f616b1d8f97bf141d96dfdf225d09ef1172271d.tar.bz2
txr-4f616b1d8f97bf141d96dfdf225d09ef1172271d.zip
linenoise: Ctrl-Z: send SIGTSTP to group, not self.
I realized this issue while implementing Ctrl-Z for the pw (Pipe Watch) program. Sending the SIGTSTP signal just to the calling process is not enough. Only that process gets suspended, which results in a weird behavior. It can be tested like this, for instance: txr | tee file Ctrl-Z must be issued twice: once to sort of suspend txr, and then again to send it to the tee program. Then the job actually suspends and the shell prompt appears. With this fix, the above situation requires only one Ctrl-Z, as expected. * linenoise/linenoise.c (history_search, show_help, edit): Don't raise(SIGTSTP), but kill(0, SIGTSTP) to send the suspend signal to all processes in the process group.
-rw-r--r--linenoise/linenoise.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/linenoise/linenoise.c b/linenoise/linenoise.c
index b3645a18..f09e9b26 100644
--- a/linenoise/linenoise.c
+++ b/linenoise/linenoise.c
@@ -828,7 +828,7 @@ static int history_search(lino_t *l)
break;
case CTL('Z'):
disable_raw_mode(l);
- raise(SIGTSTP);
+ kill(0, SIGTSTP);
enable_raw_mode(l);
}
}
@@ -930,7 +930,7 @@ static void show_help(lino_t *l)
continue;
case CTL('Z'):
disable_raw_mode(l);
- raise(SIGTSTP);
+ kill(0, SIGTSTP);
enable_raw_mode(l);
i -= 1;
continue;
@@ -2526,7 +2526,7 @@ static int edit(lino_t *l, const wchar_t *prompt)
if (l->need_refresh)
refresh_line(l);
disable_raw_mode(l);
- raise(SIGTSTP);
+ kill(0, SIGTSTP);
enable_raw_mode(l);
l->maxrows = 0;
l->dpos = dpos;