os/errno:fix os.Errno 's nil pointer derefer in linux

This commit is contained in:
luoliwoshang
2024-10-12 11:58:53 +08:00
parent 9ea88fe247
commit e9177c8932
10 changed files with 54 additions and 22 deletions

View File

@@ -264,14 +264,14 @@ func forkAndExecInChild(argv0 *c.Char, argv, envv **c.Char, chroot, dir *c.Char,
// dup2(i, i) won't clear close-on-exec flag on Linux,
// probably not elsewhere either.
if ret := os.Fcntl(c.Int(fd[i]), syscall.F_SETFD, 0); ret < 0 {
err1 = Errno(os.Errno)
err1 = Errno(os.Errno())
goto childerror
}
continue
}
// The new fd is created NOT close-on-exec,
if ret := os.Dup2(c.Int(fd[i]), c.Int(i)); ret < 0 {
err1 = Errno(os.Errno)
err1 = Errno(os.Errno())
goto childerror
}
}