From c792262b137a5f2daddac22f82e7d8d98d0d7d31 Mon Sep 17 00:00:00 2001 From: Andrew Gregory Date: Wed, 6 Aug 2014 16:36:00 -0400 Subject: wrap fgets to retry on EINTR The read() underlying fgets() can be interrupted by a signal handler causing fgets() to return NULL. Before we started handling SIGWINCH, the odds of interrupting a read were low and typically resulted in termination anyway. Replace all fgets calls with a wrapper that retries in EINTR. Signed-off-by: Andrew Gregory --- lib/libalpm/util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/libalpm/util.c') diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index 6dab0de2..43d0d7be 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -576,8 +576,9 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[]) .type = ALPM_EVENT_SCRIPTLET_INFO, .line = line }; - if(fgets(line, PATH_MAX, pipe_file) == NULL) + if(safe_fgets(line, PATH_MAX, pipe_file) == NULL) { break; + } alpm_logaction(handle, "ALPM-SCRIPTLET", "%s", line); EVENT(handle, &event); } -- cgit v1.2.3-24-g4f1b