library syscall (linux): Wait4

This commit is contained in:
xushiwei
2024-07-26 14:49:21 +08:00
parent 384e887fdb
commit a3b23e348a
5 changed files with 20 additions and 12 deletions

View File

@@ -15,6 +15,7 @@ import (
_ "unsafe"
"github.com/goplus/llgo/c"
"github.com/goplus/llgo/c/syscall"
)
// -----------------------------------------------------------------------------
@@ -78,6 +79,15 @@ func (w WaitStatus) TrapCause() int {
}
*/
func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, err error) {
var status c.Int
wpid, err = wait4(pid, &status, options, rusage)
if wstatus != nil {
*wstatus = WaitStatus(status)
}
return
}
// -----------------------------------------------------------------------------
// int pipe2(int pipefd[2], int flags);
@@ -85,13 +95,9 @@ func (w WaitStatus) TrapCause() int {
//go:linkname pipe2 C.pipe2
func pipe2(pipefd *[2]c.Int, flags c.Int) c.Int
func Pipe(p []int) error {
return Pipe2(p, 0)
}
func Pipe2(p []int, flags int) error {
if len(p) != 2 {
return EINVAL
return Errno(syscall.EINVAL)
}
var pp [2]c.Int
ret := pipe2(&pp, c.Int(flags))