[pacman-dev] [PATCH 1/2] pacman: set SA_RESTART for signal handler

Andrew Gregory andrew.gregory.8 at gmail.com
Wed Aug 6 17:13:17 EDT 2014


Calling a signal handler interrupts some functions, most notably read() and
therefore fgets().  This was less of an issue in the past because signals
generally resulted in the termination of the program, the recently added
SIGWINCH handler does not.

Signed-off-by: Andrew Gregory <andrew.gregory.8 at gmail.com>
---

For an easy and safe way to see the problem fixed by this and the next patch
resize the terminal while pacman is waiting for a user response.

 src/pacman/pacman.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index 12a4f7a..6787e72 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -1029,7 +1029,7 @@ int main(int argc, char *argv[])
 	/* Set up the structure to specify the new action. */
 	new_action.sa_handler = handler;
 	sigemptyset(&new_action.sa_mask);
-	new_action.sa_flags = 0;
+	new_action.sa_flags = SA_RESTART;
 
 	/* assign our handler to any signals we care about */
 	for(i = 0; i < sizeof(signals) / sizeof(signals[0]); i++) {
-- 
2.0.1


More information about the pacman-dev mailing list