sbase

suckless unix tools
git clone git://git.suckless.org/sbase
Log | Files | Refs | README | LICENSE

commit 651e2b0ee2bae4826c9cc9f1215cd57965676bdf
parent d098ac4abc805d6bdfc2b331de4633d7bda03b00
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sun,  4 Mar 2018 11:58:07 +0100

Set restore point before setting signal handlers

Diffstat:
Med.c | 14++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/ed.c b/ed.c @@ -1368,7 +1368,6 @@ sighup(int dummy) static void edit(void) { - setjmp(savesp); for (;;) { newcmd = 1; ocurln = curln; @@ -1388,8 +1387,6 @@ init(char *fname) { size_t len; - if (setjmp(savesp)) - return; setscratch(); if (!fname) return; @@ -1418,11 +1415,12 @@ main(int argc, char *argv[]) if (argc > 1) usage(); - signal(SIGINT, sigintr); - signal(SIGHUP, sighup); - signal(SIGQUIT, SIG_IGN); - - init(*argv); + if (!setjmp(savesp)) { + signal(SIGINT, sigintr); + signal(SIGHUP, sighup); + signal(SIGQUIT, SIG_IGN); + init(*argv); + } edit(); /* not reached */