process
// jda::process — Process management
Constants
SYS_READ = 0SYS_WRITE = 1SYS_OPEN = 2SYS_CLOSE = 3SYS_STAT = 4SYS_MMAP = 9SYS_RT_SIGACTION = 13SYS_RT_SIGPROCMASK = 14SYS_RT_SIGRETURN = 15SYS_IOCTL = 16SYS_PIPE = 22SYS_DUP = 32SYS_DUP2 = 33SYS_GETPID = 39SYS_CLONE = 56SYS_FORK = 57SYS_VFORK = 58SYS_EXECVE = 59SYS_EXIT = 60SYS_WAIT4 = 61SYS_KILL = 62SYS_GETPPID = 110SYS_GETUID = 102SYS_GETGID = 104SYS_GETEUID = 107SYS_GETEGID = 108SYS_SIGALTSTACK= 131SYS_PRCTL = 157SYS_SETPGID = 109SYS_GETPGID = 121SYS_SETSID = 112SYS_ENVIRON = -1 // accessed via auxv, not a syscallSIGHUP = 1 // hangupSIGINT = 2 // interrupt (Ctrl-C)SIGQUIT = 3 // quitSIGILL = 4 // illegal instructionSIGTRAP = 5 // trace / breakpointSIGABRT = 6 // abortSIGBUS = 7 // bus errorSIGFPE = 8 // floating-point exceptionSIGKILL = 9 // kill (cannot be caught)SIGUSR1 = 10 // user-defined 1SIGSEGV = 11 // segfaultSIGUSR2 = 12 // user-defined 2SIGPIPE = 13 // broken pipeSIGALRM = 14 // alarm clockSIGTERM = 15 // terminationSIGCHLD = 17 // child stopped or exitedSIGCONT = 18 // continueSIGSTOP = 19 // stop (cannot be caught)SIGTSTP = 20 // terminal stop (Ctrl-Z)SIGTTIN = 21 // background read from ttySIGTTOU = 22 // background write to ttySIGURG = 23 // urgent data on socketSIGWINCH = 28 // terminal resizeSIG_DFL = 0 // default actionSIG_IGN = 1 // ignore signalWNOHANG = 1 // non-blocking waitpidPR_SET_NAME = 15PR_GET_NAME = 16PR_SET_DUMPABLE = 4PR_GET_DUMPABLE = 3PR_SET_PDEATHSIG = 1 // signal sent to child when parent diesStructs
SigAction
struct SigAction {
handler: i64 // fn pointer or SIG_DFL / SIG_IGN
flags: i64 // SA_* flags
restorer: i64 // signal trampoline (kernel sets this)
mask: u64[2] // signal mask (128 bits)
}ProcInfo
struct ProcInfo {
pid: i32
ppid: i32
uid: i32
gid: i32
euid: i32
egid: i32
pgid: i32
sid: i32
}SpawnOpts
struct SpawnOpts {
stdin_fd: i32 // -1 = inherit
stdout_fd: i32 // -1 = inherit
stderr_fd: i32 // -1 = inherit
cwd: &i8 // null = inherit
env: &&i8 // null = inherit current environ
detach: i32 // 1 = new session (setsid)
}ChildProc
struct ChildProc {
pid: i32
stdin: i32 // write end of stdin pipe (-1 if not piped)
stdout: i32 // read end of stdout pipe (-1 if not piped)
stderr: i32 // read end of stderr pipe (-1 if not piped)
}WaitResult
struct WaitResult {
pid: i32
status: i32
exited: i32
code: i32 // exit code if exited
signal: i32 // signal if killed by signal
}Pipe
struct Pipe {
read_fd: i32
write_fd: i32
}Functions
Details
wifexited
fn wifexited(status: i32) -> i32 wexitstatus
fn wexitstatus(status: i32) -> i32wifsignaled
fn wifsignaled(status: i32) -> i32wtermsig
fn wtermsig(status: i32) -> i32 wifstopped
fn wifstopped(status: i32) -> i32 wstopsig
fn wstopsig(status: i32) -> i32 getpid
fn getpid() -> i32getppid
fn getppid() -> i32getuid
fn getuid() -> i32getgid
fn getgid() -> i32exit
fn exit(code: i32)abort
fn abort()fork
fn fork() -> i32execve
fn execve(path: &i8, argv: &&i8, envp: &&i8) -> i32exec_argv
fn exec_argv(path: &i8, argv: &&i8) -> i32waitpid
fn waitpid(pid: i32, status: &i32, options: i32) -> i32wait_any
fn wait_any(opts: i32) -> WaitResultrun
fn run(path: &i8, argv: &&i8) -> i32pipe2
fn pipe2(fds: &i32) -> i32dup2
fn dup2(old_fd: i32, new_fd: i32) -> i32close_fd
fn close_fd(fd: i32)spawn
fn spawn(path: &i8, argv: &&i8, opts: &SpawnOpts) -> ChildProcspawn_output
fn spawn_output(path: &i8, argv: &&i8, out: &i8, cap: i64) -> i64kill
fn kill(pid: i32, sig: i32) -> i32killpg
fn killpg(pgid: i32, sig: i32) -> i32raise_sig
fn raise_sig(sig: i32)signal
fn signal(sig: i32, handler: i64) -> i32signal_ignore
fn signal_ignore(sig: i32)signal_default
fn signal_default(sig: i32)signal_block
fn signal_block(sig: i32)signal_unblock
fn signal_unblock(sig: i32)environ
fn environ() -> &&i8process_init
fn process_init(argc: i64, argv: &&i8)getenv
fn getenv(name: &i8) -> &i8setenv
fn setenv(name: &i8, value: &i8, overwrite: i32) -> i32unsetenv
fn unsetenv(name: &i8) -> i32proc_info
fn proc_info() -> ProcInfopipe_open
fn pipe_open() -> Pipepipe_write
fn pipe_write(p: &Pipe, data: &i8, len: i64) -> i64pipe_read
fn pipe_read(p: &Pipe, buf: &i8, cap: i64) -> i64pipe_close_write
fn pipe_close_write(p: &Pipe)pipe_close_read
fn pipe_close_read(p: &Pipe) daemonize
fn daemonize() -> i32set_process_name
fn set_process_name(name: &i8)get_process_name
fn get_process_name(out: &i8)set_pdeathsig
fn set_pdeathsig(sig: i32)disable_coredump
fn disable_coredump()