files: allow to interrupt the opening of a FIFO for writing with Ctrl+C
parent
65560a583c
commit
8550c6bd93
11
src/files.c
11
src/files.c
|
@ -1543,6 +1543,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
|
||||||
/* The result of stat(). TRUE if the file exists, FALSE
|
/* The result of stat(). TRUE if the file exists, FALSE
|
||||||
* otherwise. If name is a link that points nowhere, realexists
|
* otherwise. If name is a link that points nowhere, realexists
|
||||||
* is FALSE. */
|
* is FALSE. */
|
||||||
|
struct sigaction oldaction, newaction;
|
||||||
#endif
|
#endif
|
||||||
struct stat st;
|
struct stat st;
|
||||||
/* The status fields filled in by stat(). */
|
/* The status fields filled in by stat(). */
|
||||||
|
@ -1805,12 +1806,22 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
|
||||||
statusbar(_("Writing to FIFO..."));
|
statusbar(_("Writing to FIFO..."));
|
||||||
|
|
||||||
if (f_open == NULL) {
|
if (f_open == NULL) {
|
||||||
|
#ifndef NANO_TINY
|
||||||
|
newaction.sa_handler = noop;
|
||||||
|
newaction.sa_flags = 0;
|
||||||
|
sigaction(SIGINT, &newaction, &oldaction);
|
||||||
|
enable_signals();
|
||||||
|
#endif
|
||||||
/* Now open the file in place. Use O_EXCL if tmp is TRUE. This
|
/* Now open the file in place. Use O_EXCL if tmp is TRUE. This
|
||||||
* is copied from joe, because wiggy says so *shrug*. */
|
* is copied from joe, because wiggy says so *shrug*. */
|
||||||
fd = open(realname, O_WRONLY | O_CREAT | ((method == APPEND) ?
|
fd = open(realname, O_WRONLY | O_CREAT | ((method == APPEND) ?
|
||||||
O_APPEND : (tmp ? O_EXCL : O_TRUNC)), S_IRUSR |
|
O_APPEND : (tmp ? O_EXCL : O_TRUNC)), S_IRUSR |
|
||||||
S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
|
S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
|
||||||
|
|
||||||
|
#ifndef NANO_TINY
|
||||||
|
disable_signals();
|
||||||
|
sigaction(SIGINT, &oldaction, NULL);
|
||||||
|
#endif
|
||||||
/* Set the umask back to the user's original value. */
|
/* Set the umask back to the user's original value. */
|
||||||
umask(original_umask);
|
umask(original_umask);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue