Search
SailfishOS Open Build Service
>
Projects
>
home:elros34
:
glibc
>
busybox
> _service:tar_git:0006-ash-Write-history-on-SIGHUP.patch
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File _service:tar_git:0006-ash-Write-history-on-SIGHUP.patch of Package busybox
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomi=20Lepp=C3=A4nen?= <tomi.leppanen@jolla.com> Date: Thu, 11 Feb 2021 18:08:59 +0200 Subject: [PATCH] ash: Write history on SIGHUP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If FEATURE_EDITING_SAVE_ON_EXIT is enabled, then write history on SIGHUP. This should allow most terminals to save history when closing window. Works also on SSH connection. Signed-off-by: Tomi Leppänen <tomi.leppanen@jolla.com> --- shell/ash.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/shell/ash.c b/shell/ash.c index dcaec69c5..019182f57 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -3666,6 +3666,19 @@ signal_handler(int signo) return; } +#if ENABLE_FEATURE_EDITING_SAVE_ON_EXIT + if (signo == SIGHUP) { + /* + * Terminal was closed, call exitshell() to write history etc. + * unless there is a trap set, in which case just save the history + */ + if (!trap[SIGHUP]) + exitshell(); + else if (iflag) + save_history(line_input_state); /* may be NULL */ + } +#endif + gotsig[signo - 1] = 1; pending_sig = signo; @@ -3738,6 +3751,12 @@ setsignal(int signo) if (signo == SIGCHLD) new_act = S_CATCH; +#if ENABLE_FEATURE_EDITING_SAVE_ON_EXIT + /* catch SIGHUP to write history on terminal close */ + if (signo == SIGHUP && iflag) + new_act = S_CATCH; +#endif + t = &sigmode[signo - 1]; cur_act = *t; if (cur_act == 0) { @@ -9588,6 +9607,7 @@ setinteractive(int on) setsignal(SIGINT); setsignal(SIGQUIT); setsignal(SIGTERM); + setsignal(SIGHUP); if (is_interactive > 1) { #if !ENABLE_FEATURE_SH_EXTRA_QUIET /* Looks like they want an interactive shell */ -- 2.31.1