summaryrefslogtreecommitdiff
path: root/tools.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2001-08-12 15:22:48 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2001-08-12 15:22:48 +0200
commit000ce0cf21f0eb8eb79156efdd9df615f06ce5f5 (patch)
tree9610a1ba686f7e1249709bd73a9a3ef4ee317b10 /tools.c
parent0ac6edbfc6a4128bc48372a2c913cc694f6a10eb (diff)
downloadvdr-000ce0cf21f0eb8eb79156efdd9df615f06ce5f5.tar.gz
vdr-000ce0cf21f0eb8eb79156efdd9df615f06ce5f5.tar.bz2
Made I/O more robust by handling EINTR0.9.1
Diffstat (limited to 'tools.c')
-rw-r--r--tools.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/tools.c b/tools.c
index 75e96487..e6aba17a 100644
--- a/tools.c
+++ b/tools.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: tools.c 1.38 2001/08/11 14:49:48 kls Exp $
+ * $Id: tools.c 1.39 2001/08/12 15:12:54 kls Exp $
*/
#define _GNU_SOURCE
@@ -23,9 +23,33 @@
int SysLogLevel = 3;
+ssize_t safe_read(int filedes, void *buffer, size_t size)
+{
+ for (;;) {
+ ssize_t p = read(filedes, buffer, size);
+ if (p < 0 && errno == EINTR) {
+ dsyslog(LOG_INFO, "EINTR while reading from file handle %d - retrying", filedes);
+ continue;
+ }
+ return p;
+ }
+}
+
+ssize_t safe_write(int filedes, const void *buffer, size_t size)
+{
+ for (;;) {
+ ssize_t p = write(filedes, buffer, size);
+ if (p < 0 && errno == EINTR) {
+ dsyslog(LOG_INFO, "EINTR while writing to file handle %d - retrying", filedes);
+ continue;
+ }
+ return p;
+ }
+}
+
void writechar(int filedes, char c)
{
- write(filedes, &c, sizeof(c));
+ safe_write(filedes, &c, sizeof(c));
}
char *readline(FILE *f)