| author | |
| committer | |
| log | acefcdbca58efd97bf5346eb7dae22c49efa1a3d |
| tree | 4b4f9c3320b9c6b166c41cfb7b248dba6df179d9 |
| parent | 364bc66924648c798d9eb5f70607ba8a5fb991d6 |
| signature |
2 files changed, 32 insertions(+), 11 deletions(-)
std/os/index.zig+18-11| ... | @@ -634,18 +634,25 @@ pub const PosixExecveError = error{ | ... | @@ -634,18 +634,25 @@ pub const PosixExecveError = error{ |
| 634 | 634 | ||
| 635 | fn posixExecveErrnoToErr(err: usize) PosixExecveError { | 635 | fn posixExecveErrnoToErr(err: usize) PosixExecveError { |
| 636 | assert(err > 0); | 636 | assert(err > 0); |
| 637 | return switch (err) { | 637 | switch (err) { |
| 638 | posix.EFAULT => unreachable, | 638 | posix.EFAULT => unreachable, |
| 639 | posix.E2BIG, posix.EMFILE, posix.ENAMETOOLONG, posix.ENFILE, posix.ENOMEM => error.SystemResources, | 639 | posix.E2BIG => return error.SystemResources, |
| 640 | posix.EACCES, posix.EPERM => error.AccessDenied, | 640 | posix.EMFILE => return error.SystemResources, |
| 641 | posix.EINVAL, posix.ENOEXEC => error.InvalidExe, | 641 | posix.ENAMETOOLONG => return error.SystemResources, |
| 642 | posix.EIO, posix.ELOOP => error.FileSystem, | 642 | posix.ENFILE => return error.SystemResources, |
| 643 | posix.EISDIR => error.IsDir, | 643 | posix.ENOMEM => return error.SystemResources, |
| 644 | posix.ENOENT => error.FileNotFound, | 644 | posix.EACCES => return error.AccessDenied, |
| 645 | posix.ENOTDIR => error.NotDir, | 645 | posix.EPERM => return error.AccessDenied, |
| 646 | posix.ETXTBSY => error.FileBusy, | 646 | posix.EINVAL => return error.InvalidExe, |
| 647 | else => unexpectedErrorPosix(err), | 647 | posix.ENOEXEC => return error.InvalidExe, |
| 648 | }; | 648 | posix.EIO => return error.FileSystem, |
| 649 | posix.ELOOP => return error.FileSystem, | ||
| 650 | posix.EISDIR => return error.IsDir, | ||
| 651 | posix.ENOENT => return error.FileNotFound, | ||
| 652 | posix.ENOTDIR => return error.NotDir, | ||
| 653 | posix.ETXTBSY => return error.FileBusy, | ||
| 654 | else => return unexpectedErrorPosix(err), | ||
| 655 | } | ||
| 649 | } | 656 | } |
| 650 | 657 | ||
| 651 | pub var linux_aux_raw = []usize{0} ** 38; | 658 | pub var linux_aux_raw = []usize{0} ** 38; |
std/os/linux/index.zig+14| ... | @@ -719,6 +719,15 @@ pub fn fork() usize { | ... | @@ -719,6 +719,15 @@ pub fn fork() usize { |
| 719 | return syscall0(SYS_fork); | 719 | return syscall0(SYS_fork); |
| 720 | } | 720 | } |
| 721 | 721 | ||
| 722 | /// This must be inline, and inline call the syscall function, because if the | ||
| 723 | /// child does a return it will clobber the parent's stack. | ||
| 724 | /// It is advised to avoid this function and use clone instead, because | ||
| 725 | /// the compiler is not aware of how vfork affects control flow and you may | ||
| 726 | /// see different results in optimized builds. | ||
| 727 | pub inline fn vfork() usize { | ||
| 728 | return @inlineCall(syscall0, SYS_vfork); | ||
| 729 | } | ||
| 730 | |||
| 722 | pub fn futex_wait(uaddr: usize, futex_op: u32, val: i32, timeout: ?*timespec) usize { | 731 | pub fn futex_wait(uaddr: usize, futex_op: u32, val: i32, timeout: ?*timespec) usize { |
| 723 | return syscall4(SYS_futex, uaddr, futex_op, @bitCast(u32, val), @ptrToInt(timeout)); | 732 | return syscall4(SYS_futex, uaddr, futex_op, @bitCast(u32, val), @ptrToInt(timeout)); |
| 724 | } | 733 | } |
| ... | @@ -883,6 +892,11 @@ pub fn exit(status: i32) noreturn { | ... | @@ -883,6 +892,11 @@ pub fn exit(status: i32) noreturn { |
| 883 | unreachable; | 892 | unreachable; |
| 884 | } | 893 | } |
| 885 | 894 | ||
| 895 | pub fn exit_group(status: i32) noreturn { | ||
| 896 | _ = syscall1(SYS_exit_group, @bitCast(usize, isize(status))); | ||
| 897 | unreachable; | ||
| 898 | } | ||
| 899 | |||
| 886 | pub fn getrandom(buf: [*]u8, count: usize, flags: u32) usize { | 900 | pub fn getrandom(buf: [*]u8, count: usize, flags: u32) usize { |
| 887 | return syscall3(SYS_getrandom, @ptrToInt(buf), count, @intCast(usize, flags)); | 901 | return syscall3(SYS_getrandom, @ptrToInt(buf), count, @intCast(usize, flags)); |
| 888 | } | 902 | } |