sfeed_curses

[fork] sfeed (atom feed) reader
Log | Files | Refs | README | LICENSE

commit 25a4b5688a2dccbf06bd7e2ac11380d4265e67c2
parent a20f6ab57a02d153411c47c522ba4fe1346a4dd5
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sat, 12 Sep 2020 19:18:23 +0200

line editor: improve signal handling, support SIGINT, SIGTERM

* Allow SIGINT (^C) to cancel the prompt.
* Handle SIGTERM to exit the prompt and program directly, instead of "ignoring"
  it and handling it after the prompt.
* Handling SIGWINCH while the line editor is open remains the same (the prompt
  stays open and works, but the window is not resized).

Diffstat:
Msfeed_curses.c | 12+++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/sfeed_curses.c b/sfeed_curses.c @@ -961,7 +961,17 @@ lineeditor(void) } else if (ch >= ' ') { write(1, &ch, 1); } else if (ch < 0) { - continue; /* process signals later */ + switch (sigstate) { + case 0: + case SIGWINCH: + continue; /* process signals later */ + case SIGINT: + sigstate = 0; /* exit prompt, do not quit */ + case SIGTERM: + break; /* exit prompt and quit */ + } + free(input); + return NULL; } input[nchars++] = ch; }