quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

commit db5ce1311e5a54f97ad47469f6b82281e00c15fd
parent c7f27fcac74c0063d22a2e057ab16862f58b6f13
Author: Fabrice Bellard <fabrice@bellard.org>
Date:   Thu, 11 Jan 2024 15:25:28 +0100

added os.getpid()

Diffstat:
Mquickjs/doc/quickjs.texi | 3+++
Mquickjs/quickjs-libc.c | 8++++++++
2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/quickjs/doc/quickjs.texi b/quickjs/doc/quickjs.texi @@ -757,6 +757,9 @@ object containing optional parameters: @end table +@item getpid() +Return the current process ID. + @item waitpid(pid, options) @code{waitpid} Unix system call. Return the array @code{[ret, status]}. @code{ret} contains @code{-errno} in case of error. diff --git a/quickjs/quickjs-libc.c b/quickjs/quickjs-libc.c @@ -3791,6 +3791,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) @@ -4621,6 +4628,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 ),