From: Chris Allegretta Date: Sun, 20 Jun 2004 01:13:57 +0000 (+0000) Subject: code to disable sigwinch handler to stop suspend segfault or stopping in the middle... X-Git-Tag: v1.2.4~5 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=38a330770c881c026ffcd409ff43cc55f4ab739a;p=nano.git code to disable sigwinch handler to stop suspend segfault or stopping in the middle of a file read/write git-svn-id: svn://svn.savannah.gnu.org/nano/branches/nano_1_2_branch/nano@1811 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index 326c70a2..10ca6d7b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,19 @@ CVS code - - General: - Translation updates (see po/ChangeLog for details). + - Don't run handle_sigwinch() handler if we're reading in + or writing out a file. Global variable jumpok controls + when to not run the winch handles, static resizepending + is set, handler in main to run handle_sigwinch() when set. + Should fix segfaults when nano is initially suspended while + reading in a file. + *** FIXME: WHo t credit fo finding this bug? - nano.c: main() - Don't call open_file with quiet flag set. Fixes Debian bug #246956 (no warning when trying to open non-readable file). + - Add an extra titlebar() call (useful when reading in a big + file). GNU nano 1.2.3 - 2004.01.17 - General: diff --git a/files.c b/files.c index ae436734..43fe0fb7 100644 --- a/files.c +++ b/files.c @@ -165,6 +165,10 @@ int read_file(FILE *f, const char *filename, int quiet) int line1ins = 0; int input_int; +#ifndef NANO_SMALL + jumpok = 0; +#endif + buf = charalloc(bufx); buf[0] = '\0'; @@ -334,6 +338,9 @@ int read_file(FILE *f, const char *filename, int quiet) totlines += num_lines; +#ifndef NANO_SMALL + jumpok = 1; +#endif return 1; } @@ -1346,6 +1353,7 @@ int write_file(const char *name, int tmp, int append, int nonamechange) statusbar(_("Cancelled")); return -1; } + if (!tmp) titlebar(NULL); fileptr = fileage; @@ -1487,6 +1495,9 @@ int write_file(const char *name, int tmp, int append, int nonamechange) #ifdef DEBUG dump_buffer(fileage); #endif +#ifndef NANO_SMALL + jumpok = 0; +#endif f = fdopen(fd, append == 1 ? "ab" : "wb"); if (f == NULL) { @@ -1698,6 +1709,9 @@ int write_file(const char *name, int tmp, int append, int nonamechange) cleanup_and_exit: free(realname); free(buf); +#ifndef NANO_SMALL + jumpok = 1; +#endif return retval; } diff --git a/global.c b/global.c index 6c6ed4af..b9914d7d 100644 --- a/global.c +++ b/global.c @@ -44,6 +44,7 @@ char *filename = NULL; /* Name of the file */ #ifndef NANO_SMALL struct stat originalfilestat; /* Stat for the file as we loaded it */ +int jumpok = 0; /* Okay to longjmp back to main loop */ #endif int editwinrows = 0; /* How many rows long is the edit diff --git a/nano.c b/nano.c index 813304fd..b97fccad 100644 --- a/nano.c +++ b/nano.c @@ -63,6 +63,10 @@ static struct sigaction act; /* For all our fun signal handlers */ static sigjmp_buf jmpbuf; /* Used to return to mainloop after SIGWINCH */ +#ifndef NANO_SMALL +static int resizepending = 0; /* Got a resize request while reading data */ +#endif + /* What we do when we're all set to exit */ RETSIGTYPE finish(int sigage) { @@ -2849,6 +2853,11 @@ void handle_sigwinch(int s) int result = 0; struct winsize win; + if (!jumpok) { + resizepending = 1; + return; + } + if (tty == NULL) return; fd = open(tty, O_RDWR); @@ -3445,6 +3454,14 @@ int main(int argc, char *argv[]) /* Return here after a sigwinch */ sigsetjmp(jmpbuf, 1); +#ifndef NANO_SMALL + jumpok = 1; + if (resizepending) { + resizepending = 0; + handle_sigwinch(0); + } +#endif + /* SHUT UP GCC! */ startline = 0; fill_flag_used = 0; diff --git a/proto.h b/proto.h index eeafe73c..2bdc39f8 100644 --- a/proto.h +++ b/proto.h @@ -116,6 +116,7 @@ extern regmatch_t synfilematches[1]; #ifndef NANO_SMALL extern toggle *toggles; +extern int jumpok; #endif #ifndef NANO_SMALL