mirror of
https://github.com/nim-lang/Nim.git
synced 2026-05-03 12:34:44 +00:00
Add a standard Rusage type definition and wait4, getrusage declarations (#10484)
This commit is contained in:
@@ -663,6 +663,26 @@ proc waitid*(a1: cint, a2: Id, a3: var SigInfo, a4: cint): cint {.
|
||||
proc waitpid*(a1: Pid, a2: var cint, a3: cint): Pid {.
|
||||
importc, header: "<sys/wait.h>".}
|
||||
|
||||
type Rusage* {.importc: "struct rusage", header: "<sys/resource.h>",
|
||||
bycopy.} = object
|
||||
ru_utime*, ru_stime*: Timeval # User and system time
|
||||
ru_maxrss*, ru_ixrss*, ru_idrss*, ru_isrss*, # memory sizes
|
||||
ru_minflt*, ru_majflt*, ru_nswap*, # paging activity
|
||||
ru_inblock*, ru_oublock*, ru_msgsnd*, ru_msgrcv*, # IO activity
|
||||
ru_nsignals*, ru_nvcsw*, ru_nivcsw*: clong # switching activity
|
||||
|
||||
proc wait4*(pid: Pid, status: ptr cint, options: cint, rusage: ptr Rusage): Pid
|
||||
{.importc, header: "<sys/wait.h>".}
|
||||
|
||||
const
|
||||
RUSAGE_SELF* = cint(0)
|
||||
RUSAGE_CHILDREN* = cint(-1)
|
||||
RUSAGE_THREAD* = cint(1) # This one is less std; Linux, BSD agree though.
|
||||
|
||||
# This can only fail if `who` is invalid or `rusage` ptr is invalid.
|
||||
proc getrusage*(who: cint, rusage: ptr Rusage): cint
|
||||
{.importc, header: "<sys/resource.h>", discardable.}
|
||||
|
||||
proc bsd_signal*(a1: cint, a2: proc (x: pointer) {.noconv.}) {.
|
||||
importc, header: "<signal.h>".}
|
||||
proc kill*(a1: Pid, a2: cint): cint {.importc, header: "<signal.h>".}
|
||||
|
||||
Reference in New Issue
Block a user