mirror of
https://github.com/nodejs/node-v0.x-archive.git
synced 2026-04-28 03:01:10 -04:00
fs.open should set FD_CLOEXEC
This commit is contained in:
@@ -51,6 +51,12 @@ static Persistent<String> buf_symbol;
|
||||
static char getbuf[PATH_MAX + 1];
|
||||
#endif
|
||||
|
||||
|
||||
static inline bool SetCloseOnExec(int fd) {
|
||||
return (fcntl(fd, F_SETFD, FD_CLOEXEC) != -1);
|
||||
}
|
||||
|
||||
|
||||
static int After(eio_req *req) {
|
||||
HandleScope scope;
|
||||
|
||||
@@ -100,6 +106,8 @@ static int After(eio_req *req) {
|
||||
break;
|
||||
|
||||
case EIO_OPEN:
|
||||
SetCloseOnExec(req->result);
|
||||
/* pass thru */
|
||||
case EIO_SENDFILE:
|
||||
argv[1] = Integer::New(req->result);
|
||||
break;
|
||||
@@ -621,6 +629,7 @@ 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));
|
||||
return scope.Close(Integer::New(fd));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user