diff options
author | Mattias Andrée <maandree@member.fsf.org> | 2015-12-29 18:27:53 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@member.fsf.org> | 2015-12-29 18:27:53 +0100 |
commit | fd0e45b7517af63e85cf5e8727ed279e42593a44 (patch) | |
tree | 93fdeaf6a9be78d783e9a60f273984c00eb473d8 /src | |
parent | m (diff) | |
download | sat-fd0e45b7517af63e85cf5e8727ed279e42593a44.tar.gz sat-fd0e45b7517af63e85cf5e8727ed279e42593a44.tar.bz2 sat-fd0e45b7517af63e85cf5e8727ed279e42593a44.tar.xz |
pwriten and preadn block signals
Signed-off-by: Mattias Andrée <maandree@member.fsf.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/daemon.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/daemon.c b/src/daemon.c index a8278c4..71e0226 100644 --- a/src/daemon.c +++ b/src/daemon.c @@ -21,6 +21,7 @@ */ #include "daemon.h" #include <ctype.h> +#include <signal.h> #include <stdarg.h> #include <sys/stat.h> #include <sys/file.h> @@ -43,16 +44,27 @@ extern char **environ; #define PIO(FUN) \ char *buffer = buf; \ ssize_t r, n = 0; \ + int saved_errno = 0; \ + sigset_t mask, oldmask; \ + sigfillset(&mask); \ + sigprocmask(SIG_BLOCK, &mask, &oldmask); \ while (nbyte) { \ - r = FUN(fildes, buffer, nbyte, (off_t)offset); \ - if (r < 0) return -1; \ - if (r == 0) break; \ + t (r = FUN(fildes, buffer, nbyte, (off_t)offset), r < 0); \ + if (r == 0) \ + break; \ n += r; \ nbyte -= (size_t)r; \ offset += (size_t)r; \ buffer += (size_t)r; \ } \ - return n +done: \ + sigprocmask(SIG_SETMASK, &oldmask, NULL); \ + errno = saved_errno; \ + return n; \ +fail: \ + saved_errno = errno; \ + n = -1; \ + goto done /** |