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
commitc7eb22e62fac733a070dea6cf51c247dae19f7be (patch)
tree16a1710aae8d5f1691404d145d3a08cba046158c
parent5c834d64a58d7176ff246431074707f4bf0f2abf (diff)
downloadtxr-c7eb22e62fac733a070dea6cf51c247dae19f7be.tar.gz
txr-c7eb22e62fac733a070dea6cf51c247dae19f7be.tar.bz2
txr-c7eb22e62fac733a070dea6cf51c247dae19f7be.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;