Implement getpgid syscall

This commit is contained in:
Jesús Leganés-Combarro 'piranna 2019-07-04 07:05:00 +02:00
parent d464954f58
commit 2bc16826b5

View File

@ -17,21 +17,23 @@ use byteorder::{ByteOrder, LittleEndian};
/// NOTE: TODO: These syscalls only support wasm_32 for now because they assume offsets are u32 /// NOTE: TODO: These syscalls only support wasm_32 for now because they assume offsets are u32
/// Syscall list: https://www.cs.utexas.edu/~bismith/test/syscalls/syscalls32.html /// Syscall list: https://www.cs.utexas.edu/~bismith/test/syscalls/syscalls32.html
use libc::{ use libc::{
// ENOTTY,
c_int, c_int,
c_void, c_void,
chdir, chdir,
// fcntl, setsockopt, getppid // setsockopt, getppid
close, close,
dup2, dup2,
exit, exit,
fcntl,
fstat, fstat,
getpgid,
getpid, getpid,
// readlink, // readlink,
// iovec, // iovec,
lseek, lseek,
off_t, off_t,
// open, // open,
pid_t,
read, read,
rename, rename,
// sockaddr_in, // sockaddr_in,
@ -40,6 +42,7 @@ use libc::{
// writev, // writev,
stat, stat,
write, write,
// ENOTTY,
}; };
use wasmer_runtime_core::{ use wasmer_runtime_core::{
memory::ptr::{Array, WasmPtr}, memory::ptr::{Array, WasmPtr},
@ -306,9 +309,17 @@ pub fn ___syscall125(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
-1 -1
} }
pub fn ___syscall132(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 { pub fn ___syscall132(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall132"); debug!("emscripten::___syscall132 (getpgid)");
-1
let pid: pid_t = varargs.get(ctx);
let ret = unsafe { getpgid(pid) };
debug!("=> pid: {} = {}", pid, ret);
if ret == -1 {
debug!("=> last os error: {}", Error::last_os_error(),);
}
ret
} }
pub fn ___syscall133(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 { pub fn ___syscall133(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {