mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-11-24 03:14:08 +08:00
syscall: Change Dup2 to only return an error.
From-SVN: r184222
This commit is contained in:
parent
4b386d4d6a
commit
2b120fe98e
@ -136,9 +136,8 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
|
|||||||
// so that pass 2 won't stomp on an fd it needs later.
|
// so that pass 2 won't stomp on an fd it needs later.
|
||||||
nextfd = int(len(fd))
|
nextfd = int(len(fd))
|
||||||
if pipe < nextfd {
|
if pipe < nextfd {
|
||||||
_, err2 := Dup2(pipe, nextfd)
|
err1 = raw_dup2(pipe, nextfd)
|
||||||
if err2 != nil {
|
if err1 != 0 {
|
||||||
err1 = err2.(Errno)
|
|
||||||
goto childerror
|
goto childerror
|
||||||
}
|
}
|
||||||
raw_fcntl(nextfd, F_SETFD, FD_CLOEXEC)
|
raw_fcntl(nextfd, F_SETFD, FD_CLOEXEC)
|
||||||
@ -147,9 +146,8 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
|
|||||||
}
|
}
|
||||||
for i = 0; i < len(fd); i++ {
|
for i = 0; i < len(fd); i++ {
|
||||||
if fd[i] >= 0 && fd[i] < int(i) {
|
if fd[i] >= 0 && fd[i] < int(i) {
|
||||||
_, err2 := Dup2(fd[i], nextfd)
|
err1 = raw_dup2(fd[i], nextfd)
|
||||||
if err2 != nil {
|
if err1 != 0 {
|
||||||
err1 = err2.(Errno)
|
|
||||||
goto childerror
|
goto childerror
|
||||||
}
|
}
|
||||||
raw_fcntl(nextfd, F_SETFD, FD_CLOEXEC)
|
raw_fcntl(nextfd, F_SETFD, FD_CLOEXEC)
|
||||||
@ -178,9 +176,8 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
|
|||||||
}
|
}
|
||||||
// The new fd is created NOT close-on-exec,
|
// The new fd is created NOT close-on-exec,
|
||||||
// which is exactly what we want.
|
// which is exactly what we want.
|
||||||
_, err2 := Dup2(fd[i], i)
|
err1 = raw_dup2(fd[i], i)
|
||||||
if err1 != 0 {
|
if err1 != 0 {
|
||||||
err1 = err2.(Errno)
|
|
||||||
goto childerror
|
goto childerror
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -161,9 +161,8 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
|
|||||||
// so that pass 2 won't stomp on an fd it needs later.
|
// so that pass 2 won't stomp on an fd it needs later.
|
||||||
nextfd = int(len(fd))
|
nextfd = int(len(fd))
|
||||||
if pipe < nextfd {
|
if pipe < nextfd {
|
||||||
_, err2 := Dup2(pipe, nextfd)
|
err1 = raw_dup2(pipe, nextfd)
|
||||||
if err2 != nil {
|
if err1 != 0 {
|
||||||
err1 = err2.(Errno)
|
|
||||||
goto childerror
|
goto childerror
|
||||||
}
|
}
|
||||||
raw_fcntl(nextfd, F_SETFD, FD_CLOEXEC)
|
raw_fcntl(nextfd, F_SETFD, FD_CLOEXEC)
|
||||||
@ -172,9 +171,8 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
|
|||||||
}
|
}
|
||||||
for i = 0; i < len(fd); i++ {
|
for i = 0; i < len(fd); i++ {
|
||||||
if fd[i] >= 0 && fd[i] < int(i) {
|
if fd[i] >= 0 && fd[i] < int(i) {
|
||||||
_, err2 := Dup2(fd[i], nextfd)
|
err1 = raw_dup2(fd[i], nextfd)
|
||||||
if err2 != nil {
|
if err1 != 0 {
|
||||||
err1 = err2.(Errno)
|
|
||||||
goto childerror
|
goto childerror
|
||||||
}
|
}
|
||||||
raw_fcntl(nextfd, F_SETFD, FD_CLOEXEC)
|
raw_fcntl(nextfd, F_SETFD, FD_CLOEXEC)
|
||||||
@ -203,9 +201,8 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
|
|||||||
}
|
}
|
||||||
// The new fd is created NOT close-on-exec,
|
// The new fd is created NOT close-on-exec,
|
||||||
// which is exactly what we want.
|
// which is exactly what we want.
|
||||||
_, err2 := Dup2(fd[i], i);
|
err1 = raw_dup2(fd[i], i)
|
||||||
if err2 != nil {
|
if err1 != 0 {
|
||||||
err1 = err2.(Errno)
|
|
||||||
goto childerror
|
goto childerror
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,9 @@ import (
|
|||||||
//sysnb raw_exit(status int)
|
//sysnb raw_exit(status int)
|
||||||
//_exit(status int)
|
//_exit(status int)
|
||||||
|
|
||||||
|
//sysnb raw_dup2(oldfd int, newfd int) (err Errno)
|
||||||
|
//dup2(oldfd int, newfd int) int
|
||||||
|
|
||||||
// Note: not raw, returns error rather than Errno.
|
// Note: not raw, returns error rather than Errno.
|
||||||
//sys read(fd int, p *byte, np int) (n int, err error)
|
//sys read(fd int, p *byte, np int) (n int, err error)
|
||||||
//read(fd int, buf *byte, count Size_t) Ssize_t
|
//read(fd int, buf *byte, count Size_t) Ssize_t
|
||||||
|
@ -178,7 +178,7 @@ func FDZero(set *FdSet) {
|
|||||||
//sysnb Dup(oldfd int) (fd int, err error)
|
//sysnb Dup(oldfd int) (fd int, err error)
|
||||||
//dup(oldfd int) int
|
//dup(oldfd int) int
|
||||||
|
|
||||||
//sysnb Dup2(oldfd int, newfd int) (fd int, err error)
|
//sysnb Dup2(oldfd int, newfd int) (err error)
|
||||||
//dup2(oldfd int, newfd int) int
|
//dup2(oldfd int, newfd int) int
|
||||||
|
|
||||||
//sys Exit(code int)
|
//sys Exit(code int)
|
||||||
|
Loading…
Reference in New Issue
Block a user