Check for errors on close(2) too. And lseek(2).
authorDan Gohman <gohman@apple.com>
Wed, 15 Jul 2009 16:43:01 +0000 (16:43 +0000)
committerDan Gohman <gohman@apple.com>
Wed, 15 Jul 2009 16:43:01 +0000 (16:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75793 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/raw_ostream.cpp

index 3e1a8a9765c313abe8188d8cd1afe1ae7ea7277d..0595fe47e12affae25a7dbeb565c725d68f07be3 100644 (file)
@@ -279,7 +279,8 @@ raw_fd_ostream::~raw_fd_ostream() {
   if (FD >= 0) {
     flush();
     if (ShouldClose)
-      ::close(FD);
+      if (::close(FD) != 0)
+        llvm_report_error("IO failure closing output stream.");
   }
 }
 
@@ -294,13 +295,16 @@ void raw_fd_ostream::close() {
   assert (ShouldClose);
   ShouldClose = false;
   flush();
-  ::close(FD);
+  if (::close(FD) != 0)
+    llvm_report_error("IO failure closing output stream.");
   FD = -1;
 }
 
 uint64_t raw_fd_ostream::seek(uint64_t off) {
   flush();
   pos = ::lseek(FD, off, SEEK_SET);
+  if (pos != off)
+    llvm_report_error("IO failure seeking on output stream.");
   return pos;  
 }