summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Makefile.in2
-rw-r--r--lib/safe-read.c71
-rw-r--r--old/fileutils/ChangeLog56
3 files changed, 99 insertions, 30 deletions
diff --git a/lib/Makefile.in b/lib/Makefile.in
index c9cc7968d..c08ed462b 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -90,7 +90,7 @@ libfu.a: $(OBJECTS)
# Since this directory contains two parsers, we have to be careful to avoid
# running two $(YACC)s during parallel makes. See below.
getdate.c: getdate.y
- @echo expect 9 shift/reduce conflicts
+ @echo expect 10 shift/reduce conflicts
$(YACC) $(srcdir)/getdate.y
mv y.tab.c getdate.c
diff --git a/lib/safe-read.c b/lib/safe-read.c
index d915d4e7c..2303ea111 100644
--- a/lib/safe-read.c
+++ b/lib/safe-read.c
@@ -1,4 +1,43 @@
-/* Read LEN bytes at PTR from descriptor DESC, retrying if necessary.
+/* safe-read.c -- an interface to read that retries after interrupts
+ Copyright (C) 1993, 1994 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+#ifdef HAVE_CONFIG_H
+#if defined (CONFIG_BROKETS)
+/* We use <config.h> instead of "config.h" so that a compilation
+ using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
+ (which it would do because it found this file in $srcdir). */
+#include <config.h>
+#else
+#include "config.h"
+#endif
+#endif
+
+#include <sys/types.h>
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include <errno.h>
+#ifndef STDC_HEADERS
+extern int errno;
+#endif
+
+/* Read LEN bytes at PTR from descriptor DESC, retrying if interrupted.
Return the actual number of bytes read, zero for EOF, or negative
for an error. */
@@ -8,24 +47,20 @@ safe_read (desc, ptr, len)
char *ptr;
int len;
{
- int n_remaining;
+ int n_chars;
+
+ if (len <= 0)
+ return len;
- n_remaining = len;
- while (n_remaining > 0)
- {
- int n_chars = read (desc, ptr, n_remaining);
- if (n_chars < 0)
- {
#ifdef EINTR
- if (errno == EINTR)
- continue;
-#endif
- return n_chars;
- }
- if (n_chars == 0)
- break;
- ptr += n_chars;
- n_remaining -= n_chars;
+ do
+ {
+ n_chars = read (desc, ptr, len);
}
- return len - n_remaining;
+ while (n_chars < 0 && errno == EINTR);
+#else
+ n_chars = read (desc, ptr, len);
+#endif
+
+ return n_chars;
}
diff --git a/old/fileutils/ChangeLog b/old/fileutils/ChangeLog
index fb557bbf3..b01c78d15 100644
--- a/old/fileutils/ChangeLog
+++ b/old/fileutils/ChangeLog
@@ -7,6 +7,40 @@ Mon Jan 10 01:20:38 1994 Jim Meyering (meyering@comco.com)
* man/Makefile.in (manprefix): Use binprefix as the default.
+Thu Dec 30 23:11:10 1993 Jim Meyering (meyering@comco.com)
+
+ * The following changes are necessary to avoid spurious failures
+ when a read or write system call is interrupted (e.g. by SIGTSTP).
+ A POSIX implementation of those system calls may either return
+ -1 and set errno to EINTR or return a positive value indicating
+ that a partial read or write has completed successfully. On Linux
+ 0.99.14, interrupted read and write system calls return -1/EINTR.
+ Thanks to Bruno Haible <haible@ma2s2.mathematik.uni-karlsruhe.de>
+ for pointing this out.
+
+ * full-write.c, safe-read.c: New files.
+
+ * cp.c (copy_reg): Use full_write instead of write. Handle
+ errno == EINTR (instead of failing) after read system call.
+ * dd.c (skip): Handle errno == EINTR (instead of failing) after
+ read system call.
+ (copy): Use safe_read instead of read.
+ * install.c (copy_file): Use safe_read and full_write instead of
+ read and write system calls.
+ * mv.c (copy_reg): Ditto.
+ * touch.c (utime_now): Ditto.
+
+Tue Dec 28 15:49:32 1993 Jim Meyering (meyering@comco.com)
+
+ * install.sh: New file.
+ Makefile.in [DISTFILES]: Add it.
+
+Sat Dec 18 01:12:24 1993 Jim Meyering (meyering@comco.com)
+
+ * configure.in (AC_OUTPUT): Put `touch stamp-config' in second arg
+ so it goes in config.status. This eliminates unnecessary second run
+ of configure.
+
Thu Nov 18 00:03:24 1993 Jim Meyering (meyering@comco.com)
* configure.in [STAT_STATFS2_FSIZE]: Fix test (that had obsolete
@@ -49,7 +83,7 @@ Sat Oct 16 00:25:42 1993 Jim Meyering (meyering@comco.com)
* chmod.c (change_file_mode): Reapply Oct 6 change for symlinks.
Somehow it got removed from working sources.
- * lib/Makefile.in [OBJECTS]: Change dependency to ../config.h so
+ * lib/Makefile.in [OBJECTS]: Change dependency to ../config.h so
it works when building in a subdirectory. From Rick Sladkey
(jrs@world.std.com).
@@ -59,19 +93,19 @@ Wed Oct 13 19:43:47 1993 Jim Meyering (meyering@comco.com)
that we use PATH_MAX + 1 rather than sizeof(char*) as size of
buffer in readlink call. This was causing spurious errors.
- * cp.c (copy), mv.c (do_move), rm.c (remove_file, remove_dir):
- Cast to `unsigned int' stat->st_mode printf arguments corresponding
- to %o formats to avoid warnings.
+ * cp.c (copy), mv.c (do_move), rm.c (remove_file, remove_dir):
+ Cast to `unsigned int' stat->st_mode printf arguments corresponding
+ to %o formats to avoid warnings.
- * lib/Makefile.in [DEFS]: Remove -DMVDIR. Add -DCONFIG_BROKETS.
- (rename.o): Add a specific rule. Use -DMVDIR=... here instead.
+ * lib/Makefile.in [DEFS]: Remove -DMVDIR. Add -DCONFIG_BROKETS.
+ (rename.o): Add a specific rule. Use -DMVDIR=... here instead.
- * src/Makefile.in [DEFS]: Add -DCONFIG_BROKETS.
- (distclean): Don't delete dir.c and vdir.c; they aren't
- created anymore.
+ * src/Makefile.in [DEFS]: Add -DCONFIG_BROKETS.
+ (distclean): Don't delete dir.c and vdir.c; they aren't
+ created anymore.
- * lib/Makefile.in: Make all .o files depend on $(srcdir)/../config.h.
- * src/Makefile.in: Ditto.
+ * lib/Makefile.in: Make all .o files depend on $(srcdir)/../config.h.
+ * src/Makefile.in: Ditto.
Sun Oct 10 13:38:54 1993 Jim Meyering (meyering@comco.com)