diff options
| author | Pietro Albini <pietro@pietroalbini.org> | 2018-11-15 11:04:27 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-11-15 11:04:27 +0100 |
| commit | f4ecc1f521e83c30d0c6beb3ccb9307cfa12ae9c (patch) | |
| tree | 098f9ce2fb23b287f7cff290c9432b4a664fcd56 /src/libstd/sys/redox/syscall | |
| parent | 4ec0ba9545f7c848aafc0bc1b8762507395edd41 (diff) | |
| parent | 51e2a63fafba5ab38f8ebfea803daaef2ec87d02 (diff) | |
Rollup merge of #55182 - jD91mZM2:rebased, r=alexcrichton
Redox: Update to new changes These are all cherry-picked from our fork: - Remove the `env:` scheme - Update `execve` system call to `fexec` - Interpret shebangs: these are no longer handled by the kernel, which like usual tries to be as minimal as possible
Diffstat (limited to 'src/libstd/sys/redox/syscall')
| -rw-r--r-- | src/libstd/sys/redox/syscall/call.rs | 13 | ||||
| -rw-r--r-- | src/libstd/sys/redox/syscall/flag.rs | 44 | ||||
| -rw-r--r-- | src/libstd/sys/redox/syscall/number.rs | 2 |
3 files changed, 48 insertions, 11 deletions
diff --git a/src/libstd/sys/redox/syscall/call.rs b/src/libstd/sys/redox/syscall/call.rs index f9a8bd61ac8..61cd97d6d43 100644 --- a/src/libstd/sys/redox/syscall/call.rs +++ b/src/libstd/sys/redox/syscall/call.rs @@ -82,12 +82,6 @@ pub fn dup2(fd: usize, newfd: usize, buf: &[u8]) -> Result<usize> { unsafe { syscall4(SYS_DUP2, fd, newfd, buf.as_ptr() as usize, buf.len()) } } -/// Replace the current process with a new executable -pub fn execve<T: AsRef<[u8]>>(path: T, args: &[[usize; 2]]) -> Result<usize> { - unsafe { syscall4(SYS_EXECVE, path.as_ref().as_ptr() as usize, - path.as_ref().len(), args.as_ptr() as usize, args.len()) } -} - /// Exit the current process pub fn exit(status: usize) -> Result<usize> { unsafe { syscall1(SYS_EXIT, status) } @@ -110,9 +104,10 @@ pub fn fcntl(fd: usize, cmd: usize, arg: usize) -> Result<usize> { unsafe { syscall3(SYS_FCNTL, fd, cmd, arg) } } -/// Register a file for event-based I/O -pub fn fevent(fd: usize, flags: usize) -> Result<usize> { - unsafe { syscall2(SYS_FEVENT, fd, flags) } +/// Replace the current process with a new executable +pub fn fexec(fd: usize, args: &[[usize; 2]], vars: &[[usize; 2]]) -> Result<usize> { + unsafe { syscall5(SYS_FEXEC, fd, args.as_ptr() as usize, args.len(), + vars.as_ptr() as usize, vars.len()) } } /// Map a file into memory diff --git a/src/libstd/sys/redox/syscall/flag.rs b/src/libstd/sys/redox/syscall/flag.rs index 0f61b9fa77b..0f1a2c23159 100644 --- a/src/libstd/sys/redox/syscall/flag.rs +++ b/src/libstd/sys/redox/syscall/flag.rs @@ -113,4 +113,46 @@ pub const SA_RESTART: usize = 0x10000000; pub const SA_NODEFER: usize = 0x40000000; pub const SA_RESETHAND: usize = 0x80000000; -pub const WNOHANG: usize = 1; +pub const WNOHANG: usize = 0x01; +pub const WUNTRACED: usize = 0x02; +pub const WCONTINUED: usize = 0x08; + +/// True if status indicates the child is stopped. +pub fn wifstopped(status: usize) -> bool { + (status & 0xff) == 0x7f +} + +/// If wifstopped(status), the signal that stopped the child. +pub fn wstopsig(status: usize) -> usize { + (status >> 8) & 0xff +} + +/// True if status indicates the child continued after a stop. +pub fn wifcontinued(status: usize) -> bool { + status == 0xffff +} + +/// True if STATUS indicates termination by a signal. +pub fn wifsignaled(status: usize) -> bool { + ((status & 0x7f) + 1) as i8 >= 2 +} + +/// If wifsignaled(status), the terminating signal. +pub fn wtermsig(status: usize) -> usize { + status & 0x7f +} + +/// True if status indicates normal termination. +pub fn wifexited(status: usize) -> bool { + wtermsig(status) == 0 +} + +/// If wifexited(status), the exit status. +pub fn wexitstatus(status: usize) -> usize { + (status >> 8) & 0xff +} + +/// True if status indicates a core dump was created. +pub fn wcoredump(status: usize) -> bool { + (status & 0x80) != 0 +} diff --git a/src/libstd/sys/redox/syscall/number.rs b/src/libstd/sys/redox/syscall/number.rs index 45cb40e3908..1e187565a67 100644 --- a/src/libstd/sys/redox/syscall/number.rs +++ b/src/libstd/sys/redox/syscall/number.rs @@ -36,6 +36,7 @@ pub const SYS_FCHMOD: usize = SYS_CLASS_FILE | 94; pub const SYS_FCHOWN: usize = SYS_CLASS_FILE | 207; pub const SYS_FCNTL: usize = SYS_CLASS_FILE | 55; pub const SYS_FEVENT: usize = SYS_CLASS_FILE | 927; +pub const SYS_FEXEC: usize = SYS_CLASS_FILE | 11; pub const SYS_FMAP: usize = SYS_CLASS_FILE | 90; pub const SYS_FUNMAP: usize = SYS_CLASS_FILE | 91; pub const SYS_FPATH: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 928; @@ -50,7 +51,6 @@ pub const SYS_BRK: usize = 45; pub const SYS_CHDIR: usize = 12; pub const SYS_CLOCK_GETTIME: usize = 265; pub const SYS_CLONE: usize = 120; -pub const SYS_EXECVE: usize = 11; pub const SYS_EXIT: usize = 1; pub const SYS_FUTEX: usize = 240; pub const SYS_GETCWD: usize = 183; |
