shutdown: when dying, do not install/restore a handler for Ctrl+C
First, we don't want the writing of an emergency file to be interrupted
by the user. But more important: the routine for restoring the handler
also disables SIGINT, which would leave the terminal with a non-working
Ctrl+C.
Saving an emergency file calls write_file() in a unique manner: with
thefile == NULL, fullbuffer == FALSE (even though the entire buffer
will be saved, of course) and tmp == TRUE (even though it is not a
temporary file, as it will persist after nano exits). But in fact
we want the handler for Ctrl+C installed only for normal files, not
for temporary files and not for emergency files -- the user should
not be able to interrupt the writing of those.
This fixes https://savannah.gnu.org/bugs/?61237.
Bug existed since version 4.3, commit 8550c6bd
.
master
parent
b07fb5a811
commit
e0334e861d
|
@ -1848,7 +1848,8 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
|
|||
|
||||
#ifndef NANO_TINY
|
||||
block_sigwinch(TRUE);
|
||||
install_handler_for_Ctrl_C();
|
||||
if (!tmp)
|
||||
install_handler_for_Ctrl_C();
|
||||
#endif
|
||||
|
||||
/* Now open the file. Use O_EXCL for an emergency file. */
|
||||
|
@ -1856,7 +1857,8 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
|
|||
O_APPEND : (tmp ? O_EXCL : O_TRUNC)), permissions);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
restore_handler_for_Ctrl_C();
|
||||
if (!tmp)
|
||||
restore_handler_for_Ctrl_C();
|
||||
block_sigwinch(FALSE);
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue