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 --- src/common/util-common.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/common/util-common.h') diff --git a/src/common/util-common.h b/src/common/util-common.h index 576702fa..ca8db5ab 100644 --- a/src/common/util-common.h +++ b/src/common/util-common.h @@ -20,6 +20,7 @@ #ifndef _PM_UTIL_COMMON_H #define _PM_UTIL_COMMON_H +#include #include /* struct stat */ const char *mbasename(const char *path); @@ -27,6 +28,8 @@ char *mdirname(const char *path); int llstat(char *path, struct stat *buf); +char *safe_fgets(char *s, int size, FILE *stream); + #ifndef HAVE_STRNDUP char *strndup(const char *s, size_t n); #endif -- cgit v1.2.3-24-g4f1b