unix.c, ChangeLog:
  unix.c (reserve_stdio_fds): Add safety check in case reserve_stdio_fds
  	couldn't open /dev/null.

diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog
index 04efa41..c93d12c 100644
--- a/e2fsck/ChangeLog
+++ b/e2fsck/ChangeLog
@@ -1,3 +1,8 @@
+1999-05-17    <tytso@rsts-11.mit.edu>
+
+	* unix.c (reserve_stdio_fds): Add safety check in case
+		reserve_stdio_fds couldn't open /dev/null.
+
 1999-03-14  Theodore Ts'o  <tytso@rsts-11.mit.edu>
 
 	* util.c (print_resource_track): Use mallinfo if present to get
diff --git a/e2fsck/unix.c b/e2fsck/unix.c
index 279849f..fb67f6a 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -254,6 +254,11 @@
 		fd = open("/dev/null", O_RDWR);
 		if (fd > 2)
 			break;
+		if (fd < 0) {
+			fprintf(stderr, "ERROR: Couldn't open /dev/null (%s)\n",
+				strerror(errno));
+			break;
+		}
 	}
 	close(fd);
 }