c/os: Setrlimit/Getrlimit

This commit is contained in:
xushiwei
2024-07-18 17:56:49 +08:00
parent db8cc8eb7b
commit b51df25371
7 changed files with 189 additions and 16 deletions

View File

@@ -85,6 +85,14 @@ func Kill(pid int, signum Signal) (err error) {
return Errno(ret)
}
func fork() (uintptr, Errno) {
ret := os.Fork()
if ret >= 0 {
return uintptr(ret), Errno(0)
}
return 0, Errno(os.Errno)
}
func wait4(pid int, wstatus *c.Int, options int, rusage *syscall.Rusage) (wpid int, err error) {
ret := os.Wait4(os.PidT(pid), wstatus, c.Int(options), rusage)
if ret >= 0 {
@@ -164,3 +172,21 @@ func Pipe(p []int) (err error) {
}
return Errno(ret)
}
type Rlimit syscall.Rlimit
func Getrlimit(which int, lim *Rlimit) (err error) {
ret := os.Getrlimit(c.Int(which), (*syscall.Rlimit)(lim))
if ret == 0 {
return nil
}
return Errno(ret)
}
func setrlimit(which int, lim *Rlimit) (err error) {
ret := os.Setrlimit(c.Int(which), (*syscall.Rlimit)(lim))
if ret == 0 {
return nil
}
return Errno(ret)
}