add std.os.linux.vfork and std.os.linux.exit_group

This commit is contained in:
Andrew Kelley
2018-10-02 14:08:32 -04:00
parent 364bc66924
commit acefcdbca5
2 changed files with 32 additions and 11 deletions

View File

@@ -719,6 +719,15 @@ pub fn fork() usize {
return syscall0(SYS_fork);
}
/// This must be inline, and inline call the syscall function, because if the
/// child does a return it will clobber the parent's stack.
/// It is advised to avoid this function and use clone instead, because
/// the compiler is not aware of how vfork affects control flow and you may
/// see different results in optimized builds.
pub inline fn vfork() usize {
return @inlineCall(syscall0, SYS_vfork);
}
pub fn futex_wait(uaddr: usize, futex_op: u32, val: i32, timeout: ?*timespec) usize {
return syscall4(SYS_futex, uaddr, futex_op, @bitCast(u32, val), @ptrToInt(timeout));
}
@@ -883,6 +892,11 @@ pub fn exit(status: i32) noreturn {
unreachable;
}
pub fn exit_group(status: i32) noreturn {
_ = syscall1(SYS_exit_group, @bitCast(usize, isize(status)));
unreachable;
}
pub fn getrandom(buf: [*]u8, count: usize, flags: u32) usize {
return syscall3(SYS_getrandom, @ptrToInt(buf), count, @intCast(usize, flags));
}