authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-05-02 03:38:05-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-05-02 03:38:05-04:00
log6546c74825ec36cf6f065f1adb366073c00433ca
tree80027b8242eafd26399f3fdf8be29caefa4350a2
parent92f3e9c92acd6cba98a8a8f46341d138f89aae53

child process: no need to remove O_CLOEXEC before execve


1 files changed, 0 insertions(+), 10 deletions(-)

lib/std/child_process.zig-10
...@@ -421,16 +421,6 @@ pub const ChildProcess = struct {...@@ -421,16 +421,6 @@ pub const ChildProcess = struct {
421 }421 }
422422
423 if (self.cwd_dir) |cwd| {423 if (self.cwd_dir) |cwd| {
424 // Remove the O_CLOEXEC flag. This is the only safe time to do it, between fork() and execve().
425 var flags = os.fcntl(cwd.fd, os.F_GETFD, 0) catch |err| switch (err) {
426 error.Locked => unreachable,
427 else => |e| forkChildErrReport(err_pipe[1], e),
428 };
429 flags &= ~@as(u32, os.O_CLOEXEC);
430 _ = os.fcntl(cwd.fd, os.F_SETFD, flags) catch |err| switch (err) {
431 error.Locked => unreachable,
432 else => |e| forkChildErrReport(err_pipe[1], e),
433 };
434 os.fchdir(cwd.fd) catch |err| forkChildErrReport(err_pipe[1], err);424 os.fchdir(cwd.fd) catch |err| forkChildErrReport(err_pipe[1], err);
435 } else if (self.cwd) |cwd| {425 } else if (self.cwd) |cwd| {
436 os.chdir(cwd) catch |err| forkChildErrReport(err_pipe[1], err);426 os.chdir(cwd) catch |err| forkChildErrReport(err_pipe[1], err);