Thanks for your work on this project.
Attached is a simple patch to expose *getpid *function to JS code
PR https://github.com/bellard/quickjs/pull/60 has also been open
Regards
diff --git a/quickjs-libc.c b/quickjs-libc.c
index e180dd0..c924715 100644
--- a/quickjs-libc.c
+++ b/quickjs-libc.c
@@ -3030,6 +3030,13 @@ static JSValue js_os_exec(JSContext *ctx, JSValueConst
this_val,
goto done;
}
+/* getpid() -> pid */
+static JSValue js_os_getpid(JSContext *ctx, JSValueConst this_val,
+ int argc, JSValueConst *argv)
+{
+ return JS_NewInt32(ctx, getpid());
+}
+
/* waitpid(pid, block) -> [pid, status] */
static JSValue js_os_waitpid(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)
@@ -3650,6 +3657,7 @@ static const JSCFunctionListEntry js_os_funcs[] = {
JS_CFUNC_DEF("symlink", 2, js_os_symlink ),
JS_CFUNC_DEF("readlink", 1, js_os_readlink ),
JS_CFUNC_DEF("exec", 1, js_os_exec ),
+ JS_CFUNC_DEF("getpid", 0, js_os_getpid ),
JS_CFUNC_DEF("waitpid", 2, js_os_waitpid ),
OS_FLAG(WNOHANG),
JS_CFUNC_DEF("pipe", 0, js_os_pipe ),