From a85e02fe6e25ca8a1251d2ff9652d309d1c981f1 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Sat, 1 Dec 2018 11:33:17 -0800 Subject: [PATCH] Added ___syscall57 emscripten syscall --- src/apis/emscripten/mod.rs | 5 +++++ src/apis/emscripten/syscalls.rs | 17 ++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/apis/emscripten/mod.rs b/src/apis/emscripten/mod.rs index 03e0308b8..d1b8a20c1 100644 --- a/src/apis/emscripten/mod.rs +++ b/src/apis/emscripten/mod.rs @@ -271,6 +271,11 @@ pub fn generate_emscripten_env<'a, 'b>() -> ImportObject<&'a str, &'b str> { "___syscall142", ImportValue::Func(syscalls::___syscall142 as _), ); + import_object.set( + "env", + "___syscall57", + ImportValue::Func(syscalls::___syscall57 as _), + ); // Process import_object.set("env", "abort", ImportValue::Func(process::em_abort as _)); diff --git a/src/apis/emscripten/syscalls.rs b/src/apis/emscripten/syscalls.rs index 0a42d0dba..33d6498e0 100644 --- a/src/apis/emscripten/syscalls.rs +++ b/src/apis/emscripten/syscalls.rs @@ -52,6 +52,7 @@ use libc::{ writev, select, FIONBIO, + setpgid, }; /// exit @@ -728,4 +729,18 @@ pub extern "C" fn ___syscall142( let writefds_ptr = instance.memory_offset_addr(0, writefds as _) as _; unsafe { select(nfds, readfds_ptr, writefds_ptr, 0 as _, 0 as _) } -} \ No newline at end of file +} + +// setpgid +pub extern "C" fn ___syscall57( + _which: c_int, + mut varargs: VarArgs, + instance: &mut Instance, +) -> c_int { + debug!("emscripten::___syscall57 (setpgid)"); + let pid: i32 = varargs.get(instance); + let pgid: i32 = varargs.get(instance); + unsafe { + setpgid(pid, pgid) + } +}