Fix wrong error handling at Open() after open(2) in sync mode
authoravz <a.arepo@gmail.com>
Sat, 25 Jun 2011 09:42:20 +0000 (02:42 -0700)
committerBen Noordhuis <info@bnoordhuis.nl>
Tue, 5 Jul 2011 00:05:37 +0000 (02:05 +0200)
src/node_file.cc

index ad0c7b4..660e330 100644 (file)
@@ -664,8 +664,8 @@ static Handle<Value> Open(const Arguments& args) {
     ASYNC_CALL(open, args[3], *path, flags, mode)
   } else {
     int fd = open(*path, flags, mode);
-    SetCloseOnExec(fd);
     if (fd < 0) return ThrowException(ErrnoException(errno, NULL, "", *path));
+    SetCloseOnExec(fd);
     return scope.Close(Integer::New(fd));
   }
 }