|
@ -51,6 +51,12 @@ static Persistent<String> buf_symbol; |
|
|
static char getbuf[PATH_MAX + 1]; |
|
|
static char getbuf[PATH_MAX + 1]; |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static inline bool SetCloseOnExec(int fd) { |
|
|
|
|
|
return (fcntl(fd, F_SETFD, FD_CLOEXEC) != -1); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int After(eio_req *req) { |
|
|
static int After(eio_req *req) { |
|
|
HandleScope scope; |
|
|
HandleScope scope; |
|
|
|
|
|
|
|
@ -100,6 +106,8 @@ static int After(eio_req *req) { |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
case EIO_OPEN: |
|
|
case EIO_OPEN: |
|
|
|
|
|
SetCloseOnExec(req->result); |
|
|
|
|
|
/* pass thru */ |
|
|
case EIO_SENDFILE: |
|
|
case EIO_SENDFILE: |
|
|
argv[1] = Integer::New(req->result); |
|
|
argv[1] = Integer::New(req->result); |
|
|
break; |
|
|
break; |
|
@ -621,6 +629,7 @@ static Handle<Value> Open(const Arguments& args) { |
|
|
ASYNC_CALL(open, args[3], *path, flags, mode) |
|
|
ASYNC_CALL(open, args[3], *path, flags, mode) |
|
|
} else { |
|
|
} else { |
|
|
int fd = open(*path, flags, mode); |
|
|
int fd = open(*path, flags, mode); |
|
|
|
|
|
SetCloseOnExec(fd); |
|
|
if (fd < 0) return ThrowException(ErrnoException(errno, NULL, "", *path)); |
|
|
if (fd < 0) return ThrowException(ErrnoException(errno, NULL, "", *path)); |
|
|
return scope.Close(Integer::New(fd)); |
|
|
return scope.Close(Integer::New(fd)); |
|
|
} |
|
|
} |
|
|