From a829707b1689bdcb97eb34baaaa2e27855dbcffa Mon Sep 17 00:00:00 2001 From: weishu Date: Fri, 23 Feb 2024 09:16:00 +0800 Subject: [PATCH] js: Allow `spawn(command, options)` call, fix memory leak --- js/index.js | 8 ++++++++ js/package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/js/index.js b/js/index.js index a7a7422c..7d547425 100644 --- a/js/index.js +++ b/js/index.js @@ -71,6 +71,9 @@ function Stdio() { export function spawn(command, args, options) { if (typeof args === "undefined") { args = []; + } else if (typeof args === "object") { + // allow for (command, options) signature + options = args; } if (typeof options === "undefined") { @@ -84,6 +87,11 @@ function Stdio() { function cleanup(name) { delete window[name]; } + + child.on("exit", code => { + cleanup(childCallbackName); + }); + try { ksu.spawn( command, diff --git a/js/package.json b/js/package.json index f5fce642..8fb1650a 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "kernelsu", - "version": "1.0.3", + "version": "1.0.5", "description": "Library for KernelSU's module WebUI", "main": "index.js", "scripts": {