@ai-ecoverse/slicc-jsh 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/host/main.mjs +1 -1
- package/dist/jsh.mjs +219 -50
- package/dist/meta-main.json +1 -1
- package/dist/node.mjs +219 -50
- package/package.json +1 -1
package/dist/host/main.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import vm from "node:vm";
|
|
|
10
10
|
// package.json
|
|
11
11
|
var package_default = {
|
|
12
12
|
name: "@ai-ecoverse/slicc-jsh",
|
|
13
|
-
version: "0.3.
|
|
13
|
+
version: "0.3.2",
|
|
14
14
|
description: "Node.js-compatible runtime for slicc-kernel: the node and jsh commands (abi: js)",
|
|
15
15
|
type: "module",
|
|
16
16
|
license: "Apache-2.0",
|
package/dist/jsh.mjs
CHANGED
|
@@ -1585,7 +1585,7 @@ function assignProcessExitCode(value) {
|
|
|
1585
1585
|
// package.json
|
|
1586
1586
|
var package_default = {
|
|
1587
1587
|
name: "@ai-ecoverse/slicc-jsh",
|
|
1588
|
-
version: "0.3.
|
|
1588
|
+
version: "0.3.2",
|
|
1589
1589
|
description: "Node.js-compatible runtime for slicc-kernel: the node and jsh commands (abi: js)",
|
|
1590
1590
|
type: "module",
|
|
1591
1591
|
license: "Apache-2.0",
|
|
@@ -10818,6 +10818,9 @@ function notSupported(name) {
|
|
|
10818
10818
|
err.code = "ERR_NOT_SUPPORTED";
|
|
10819
10819
|
throw err;
|
|
10820
10820
|
}
|
|
10821
|
+
function isExitError(err) {
|
|
10822
|
+
return err?.name === "NodeExitError";
|
|
10823
|
+
}
|
|
10821
10824
|
function normalizeArgs(file, args, options, callback) {
|
|
10822
10825
|
if (typeof args === "function") {
|
|
10823
10826
|
return { args: [], options: {}, callback: args };
|
|
@@ -10857,11 +10860,16 @@ function signalName(sig) {
|
|
|
10857
10860
|
if (typeof sig === "number") return SIGNAL_NAMES[sig] ?? String(sig);
|
|
10858
10861
|
return null;
|
|
10859
10862
|
}
|
|
10863
|
+
function decodeOutput(buf, encoding) {
|
|
10864
|
+
if (encoding === "buffer" || encoding === null) return buf;
|
|
10865
|
+
const enc = encoding === void 0 ? "utf8" : encoding;
|
|
10866
|
+
return buf.toString(enc);
|
|
10867
|
+
}
|
|
10860
10868
|
function spawnError(command, args, code, message) {
|
|
10861
10869
|
const err = new Error(message ?? `spawn ${command} ${code}`);
|
|
10862
10870
|
err.code = code;
|
|
10863
10871
|
err.errno = code === "ENOENT" ? -2 : void 0;
|
|
10864
|
-
err.syscall =
|
|
10872
|
+
err.syscall = `spawn ${command}`;
|
|
10865
10873
|
err.path = command;
|
|
10866
10874
|
err.spawnargs = args;
|
|
10867
10875
|
return err;
|
|
@@ -10883,16 +10891,22 @@ function createChildProcess({ ctx, process: process2, Buffer: Buffer2, handles,
|
|
|
10883
10891
|
this.#kernel = null;
|
|
10884
10892
|
this.#handle = null;
|
|
10885
10893
|
this.#closing = false;
|
|
10894
|
+
this.#exited = false;
|
|
10886
10895
|
}
|
|
10887
10896
|
#kernel;
|
|
10888
10897
|
#handle;
|
|
10889
10898
|
#closing;
|
|
10899
|
+
#exited;
|
|
10890
10900
|
kill(signal = "SIGTERM") {
|
|
10901
|
+
if (this.#exited || this.#closing || !this.#kernel) return false;
|
|
10891
10902
|
const name = signalName(signal) ?? "SIGTERM";
|
|
10892
10903
|
this.killed = true;
|
|
10893
|
-
if (!this.#kernel) return false;
|
|
10894
10904
|
try {
|
|
10895
10905
|
const ret = this.#kernel.kill(name);
|
|
10906
|
+
if (ret != null && typeof ret.then === "function") {
|
|
10907
|
+
ret.catch(() => {
|
|
10908
|
+
});
|
|
10909
|
+
}
|
|
10896
10910
|
return ret !== false;
|
|
10897
10911
|
} catch {
|
|
10898
10912
|
return false;
|
|
@@ -10923,6 +10937,7 @@ function createChildProcess({ ctx, process: process2, Buffer: Buffer2, handles,
|
|
|
10923
10937
|
/** @internal */
|
|
10924
10938
|
_markClosing() {
|
|
10925
10939
|
this.#closing = true;
|
|
10940
|
+
this.#exited = true;
|
|
10926
10941
|
}
|
|
10927
10942
|
get _closing() {
|
|
10928
10943
|
return this.#closing;
|
|
@@ -11009,20 +11024,46 @@ function createChildProcess({ ctx, process: process2, Buffer: Buffer2, handles,
|
|
|
11009
11024
|
if (child.stderr?._sliccPump) pumps.push(child.stderr._sliccPump(kernelChild.stderr));
|
|
11010
11025
|
child._stdioPumps = Promise.all(pumps);
|
|
11011
11026
|
}
|
|
11027
|
+
function safeEmit(child, event, ...args) {
|
|
11028
|
+
try {
|
|
11029
|
+
child.emit(event, ...args);
|
|
11030
|
+
} catch (err) {
|
|
11031
|
+
if (isExitError(err)) return err;
|
|
11032
|
+
throw err;
|
|
11033
|
+
}
|
|
11034
|
+
return null;
|
|
11035
|
+
}
|
|
11012
11036
|
function finish(child, code, signal) {
|
|
11013
11037
|
if (child._closing) return;
|
|
11014
11038
|
child._markClosing();
|
|
11015
11039
|
child.exitCode = code;
|
|
11016
11040
|
child.signalCode = signal;
|
|
11017
|
-
child
|
|
11041
|
+
const exitErr = safeEmit(child, "exit", code, signal);
|
|
11042
|
+
if (exitErr) {
|
|
11043
|
+
child._release();
|
|
11044
|
+
handles.notify?.();
|
|
11045
|
+
return;
|
|
11046
|
+
}
|
|
11018
11047
|
const after = child._stdioPumps ?? Promise.resolve();
|
|
11019
11048
|
trackPromise(handles, after);
|
|
11020
11049
|
after.finally(() => {
|
|
11021
|
-
child
|
|
11050
|
+
const closeErr = safeEmit(child, "close", code, signal);
|
|
11022
11051
|
child._release();
|
|
11023
11052
|
handles.notify?.();
|
|
11053
|
+
if (closeErr) return;
|
|
11024
11054
|
});
|
|
11025
11055
|
}
|
|
11056
|
+
function decodeWait(status) {
|
|
11057
|
+
const sigNum = status?.signal;
|
|
11058
|
+
if (sigNum != null && sigNum !== 0) {
|
|
11059
|
+
return { code: null, signal: SIGNAL_NAMES[sigNum] ?? String(sigNum) };
|
|
11060
|
+
}
|
|
11061
|
+
const code = typeof status?.status === "number" ? status.status : 0;
|
|
11062
|
+
if (code > 128 && code < 128 + 32 && SIGNAL_NAMES[code - 128]) {
|
|
11063
|
+
return { code: null, signal: SIGNAL_NAMES[code - 128] };
|
|
11064
|
+
}
|
|
11065
|
+
return { code, signal: null };
|
|
11066
|
+
}
|
|
11026
11067
|
function startSpawn(child, file, args, options, stdio) {
|
|
11027
11068
|
const cwd = options.cwd != null ? String(options.cwd) : process2.cwd();
|
|
11028
11069
|
const env = options.env ? { ...options.env } : { ...process2.env };
|
|
@@ -11042,22 +11083,18 @@ function createChildProcess({ ctx, process: process2, Buffer: Buffer2, handles,
|
|
|
11042
11083
|
(kernelChild) => {
|
|
11043
11084
|
child._bindKernel(kernelChild);
|
|
11044
11085
|
connectStdio(child, kernelChild);
|
|
11045
|
-
child
|
|
11086
|
+
const spawnErr = safeEmit(child, "spawn");
|
|
11087
|
+
if (spawnErr) return;
|
|
11046
11088
|
const waitP = kernelChild.wait();
|
|
11047
11089
|
trackPromise(handles, waitP);
|
|
11048
11090
|
waitP.then(
|
|
11049
11091
|
(status) => {
|
|
11050
|
-
const
|
|
11051
|
-
|
|
11052
|
-
const name = SIGNAL_NAMES[sigNum] ?? String(sigNum);
|
|
11053
|
-
finish(child, null, name);
|
|
11054
|
-
} else {
|
|
11055
|
-
const code = typeof status?.status === "number" ? status.status : 0;
|
|
11056
|
-
finish(child, code, null);
|
|
11057
|
-
}
|
|
11092
|
+
const { code, signal } = decodeWait(status);
|
|
11093
|
+
finish(child, code, signal);
|
|
11058
11094
|
},
|
|
11059
11095
|
(err) => {
|
|
11060
|
-
|
|
11096
|
+
if (isExitError(err)) return;
|
|
11097
|
+
safeEmit(child, "error", err);
|
|
11061
11098
|
finish(child, 1, null);
|
|
11062
11099
|
}
|
|
11063
11100
|
);
|
|
@@ -11074,15 +11111,23 @@ function createChildProcess({ ctx, process: process2, Buffer: Buffer2, handles,
|
|
|
11074
11111
|
} catch {
|
|
11075
11112
|
}
|
|
11076
11113
|
process2.nextTick(() => {
|
|
11077
|
-
child
|
|
11114
|
+
const emitErr = safeEmit(child, "error", error);
|
|
11115
|
+
if (emitErr) {
|
|
11116
|
+
child._release();
|
|
11117
|
+
handles.notify?.();
|
|
11118
|
+
return;
|
|
11119
|
+
}
|
|
11078
11120
|
if (code === "ENOENT") {
|
|
11079
11121
|
child.exitCode = -2;
|
|
11080
|
-
child.
|
|
11122
|
+
child._markClosing();
|
|
11123
|
+
setTimeout(() => {
|
|
11124
|
+
safeEmit(child, "close", -2, null);
|
|
11125
|
+
child._release();
|
|
11126
|
+
handles.notify?.();
|
|
11127
|
+
}, 20);
|
|
11081
11128
|
} else {
|
|
11082
11129
|
finish(child, 1, null);
|
|
11083
11130
|
}
|
|
11084
|
-
child._release();
|
|
11085
|
-
handles.notify?.();
|
|
11086
11131
|
});
|
|
11087
11132
|
}
|
|
11088
11133
|
);
|
|
@@ -11117,53 +11162,95 @@ function createChildProcess({ ctx, process: process2, Buffer: Buffer2, handles,
|
|
|
11117
11162
|
const child = spawn(String(file), norm.args, opts);
|
|
11118
11163
|
if (!norm.callback) return child;
|
|
11119
11164
|
const maxBuffer = opts.maxBuffer ?? 1024 * 1024;
|
|
11165
|
+
const encoding = opts.encoding;
|
|
11166
|
+
const killSignal = signalName(opts.killSignal) ?? "SIGTERM";
|
|
11120
11167
|
let stdout = Buffer2.alloc(0);
|
|
11121
11168
|
let stderr = Buffer2.alloc(0);
|
|
11122
11169
|
let exited = false;
|
|
11170
|
+
let timedOut = false;
|
|
11171
|
+
let timer;
|
|
11172
|
+
const clearTimer = () => {
|
|
11173
|
+
if (timer) {
|
|
11174
|
+
clearTimeout(timer);
|
|
11175
|
+
timer = void 0;
|
|
11176
|
+
}
|
|
11177
|
+
};
|
|
11123
11178
|
const done = (err) => {
|
|
11124
11179
|
if (exited) return;
|
|
11125
11180
|
exited = true;
|
|
11126
|
-
|
|
11127
|
-
const out =
|
|
11128
|
-
const errOut =
|
|
11181
|
+
clearTimer();
|
|
11182
|
+
const out = decodeOutput(stdout, encoding);
|
|
11183
|
+
const errOut = decodeOutput(stderr, encoding);
|
|
11184
|
+
if (err) {
|
|
11185
|
+
err.stdout = out;
|
|
11186
|
+
err.stderr = errOut;
|
|
11187
|
+
}
|
|
11129
11188
|
norm.callback(err, out, errOut);
|
|
11130
11189
|
};
|
|
11131
|
-
if (
|
|
11132
|
-
|
|
11133
|
-
|
|
11190
|
+
if (opts.timeout != null && opts.timeout > 0) {
|
|
11191
|
+
timer = setTimeout(() => {
|
|
11192
|
+
timedOut = true;
|
|
11193
|
+
child.kill(killSignal);
|
|
11194
|
+
}, Number(opts.timeout));
|
|
11195
|
+
timer.unref?.();
|
|
11196
|
+
}
|
|
11197
|
+
const append = (kind, chunk) => {
|
|
11198
|
+
const buf = Buffer2.isBuffer(chunk) ? chunk : Buffer2.from(chunk);
|
|
11199
|
+
if (kind === "stdout") {
|
|
11200
|
+
stdout = Buffer2.concat([stdout, buf]);
|
|
11134
11201
|
if (stdout.length > maxBuffer) {
|
|
11202
|
+
stdout = stdout.subarray(0, maxBuffer);
|
|
11135
11203
|
child.kill();
|
|
11136
|
-
const err = new Error("stdout maxBuffer exceeded");
|
|
11204
|
+
const err = new Error("stdout maxBuffer length exceeded");
|
|
11137
11205
|
err.code = "ERR_CHILD_PROCESS_STDIO_MAXBUFFER";
|
|
11138
11206
|
done(err);
|
|
11207
|
+
return false;
|
|
11139
11208
|
}
|
|
11140
|
-
}
|
|
11141
|
-
|
|
11142
|
-
if (child.stderr) {
|
|
11143
|
-
child.stderr.on("data", (chunk) => {
|
|
11144
|
-
stderr = Buffer2.concat([stderr, Buffer2.isBuffer(chunk) ? chunk : Buffer2.from(chunk)]);
|
|
11209
|
+
} else {
|
|
11210
|
+
stderr = Buffer2.concat([stderr, buf]);
|
|
11145
11211
|
if (stderr.length > maxBuffer) {
|
|
11212
|
+
stderr = stderr.subarray(0, maxBuffer);
|
|
11146
11213
|
child.kill();
|
|
11147
|
-
const err = new Error("stderr maxBuffer exceeded");
|
|
11214
|
+
const err = new Error("stderr maxBuffer length exceeded");
|
|
11148
11215
|
err.code = "ERR_CHILD_PROCESS_STDIO_MAXBUFFER";
|
|
11149
11216
|
done(err);
|
|
11217
|
+
return false;
|
|
11150
11218
|
}
|
|
11219
|
+
}
|
|
11220
|
+
return true;
|
|
11221
|
+
};
|
|
11222
|
+
if (child.stdout) {
|
|
11223
|
+
child.stdout.on("data", (chunk) => {
|
|
11224
|
+
append("stdout", chunk);
|
|
11225
|
+
});
|
|
11226
|
+
}
|
|
11227
|
+
if (child.stderr) {
|
|
11228
|
+
child.stderr.on("data", (chunk) => {
|
|
11229
|
+
append("stderr", chunk);
|
|
11151
11230
|
});
|
|
11152
11231
|
}
|
|
11153
11232
|
child.on("error", (err) => done(err));
|
|
11154
11233
|
child.on("close", (code, signal) => {
|
|
11155
11234
|
if (exited) return;
|
|
11235
|
+
const cmd = opts._execCmd != null ? String(opts._execCmd) : `${file} ${norm.args.join(" ")}`.trim();
|
|
11236
|
+
if (timedOut) {
|
|
11237
|
+
const err2 = new Error(`Command failed: ${cmd}`);
|
|
11238
|
+
err2.code = null;
|
|
11239
|
+
err2.killed = true;
|
|
11240
|
+
err2.signal = killSignal;
|
|
11241
|
+
err2.cmd = cmd;
|
|
11242
|
+
done(err2);
|
|
11243
|
+
return;
|
|
11244
|
+
}
|
|
11156
11245
|
if (code === 0 && !signal) {
|
|
11157
11246
|
done(null);
|
|
11158
11247
|
return;
|
|
11159
11248
|
}
|
|
11160
|
-
const err = new Error(`Command failed: ${
|
|
11249
|
+
const err = new Error(`Command failed: ${cmd}`);
|
|
11161
11250
|
err.code = code;
|
|
11162
11251
|
err.killed = child.killed;
|
|
11163
11252
|
err.signal = signal;
|
|
11164
|
-
err.cmd =
|
|
11165
|
-
err.stdout = opts.encoding ? stdout.toString(opts.encoding) : stdout;
|
|
11166
|
-
err.stderr = opts.encoding ? stderr.toString(opts.encoding) : stderr;
|
|
11253
|
+
err.cmd = cmd;
|
|
11167
11254
|
done(err);
|
|
11168
11255
|
});
|
|
11169
11256
|
return child;
|
|
@@ -11177,7 +11264,8 @@ function createChildProcess({ ctx, process: process2, Buffer: Buffer2, handles,
|
|
|
11177
11264
|
}
|
|
11178
11265
|
opts = opts && typeof opts === "object" ? opts : {};
|
|
11179
11266
|
const shell = typeof opts.shell === "string" ? opts.shell : "sh";
|
|
11180
|
-
|
|
11267
|
+
const cmd = String(command);
|
|
11268
|
+
return execFile(shell, ["-c", cmd], { ...opts, shell: false, _execCmd: cmd }, cb);
|
|
11181
11269
|
}
|
|
11182
11270
|
return {
|
|
11183
11271
|
spawn,
|
|
@@ -16019,6 +16107,8 @@ function createNextTick() {
|
|
|
16019
16107
|
|
|
16020
16108
|
// src/runtime/process.mjs
|
|
16021
16109
|
var NODE_SHIM_VERSION = "22.22.0";
|
|
16110
|
+
var SIGNAL_EXIT_CODES = { SIGTERM: 143, SIGINT: 130, SIGHUP: 129, SIGKILL: 137 };
|
|
16111
|
+
var SIGNAL_BY_NUMBER = { 1: "SIGHUP", 2: "SIGINT", 9: "SIGKILL", 15: "SIGTERM" };
|
|
16022
16112
|
function toBytes2(value) {
|
|
16023
16113
|
if (typeof value === "string") return value;
|
|
16024
16114
|
if (value instanceof Uint8Array) return value;
|
|
@@ -16210,6 +16300,69 @@ function createStdin(ctx, handles, Buffer2) {
|
|
|
16210
16300
|
}
|
|
16211
16301
|
};
|
|
16212
16302
|
}
|
|
16303
|
+
function readProcessCreds(ctx) {
|
|
16304
|
+
const fromProc = (text) => {
|
|
16305
|
+
let uid = 0;
|
|
16306
|
+
let euid = 0;
|
|
16307
|
+
let gid = 0;
|
|
16308
|
+
let egid = 0;
|
|
16309
|
+
let groups = [0];
|
|
16310
|
+
for (const line of text.split("\n")) {
|
|
16311
|
+
if (line.startsWith("Uid:")) {
|
|
16312
|
+
const parts = line.slice(4).trim().split(/\s+/).map(Number);
|
|
16313
|
+
uid = parts[0] ?? 0;
|
|
16314
|
+
euid = parts[1] ?? uid;
|
|
16315
|
+
} else if (line.startsWith("Gid:")) {
|
|
16316
|
+
const parts = line.slice(4).trim().split(/\s+/).map(Number);
|
|
16317
|
+
gid = parts[0] ?? 0;
|
|
16318
|
+
egid = parts[1] ?? gid;
|
|
16319
|
+
} else if (line.startsWith("Groups:")) {
|
|
16320
|
+
const parts = line.slice(7).trim().split(/\s+/).filter(Boolean).map(Number);
|
|
16321
|
+
if (parts.length) groups = parts;
|
|
16322
|
+
}
|
|
16323
|
+
}
|
|
16324
|
+
return { uid, euid, gid, egid, groups };
|
|
16325
|
+
};
|
|
16326
|
+
const tryRead = (path) => {
|
|
16327
|
+
try {
|
|
16328
|
+
const bytes = ctx.sync?.fs?.readFile?.(path);
|
|
16329
|
+
if (!bytes) return null;
|
|
16330
|
+
return typeof bytes === "string" ? bytes : new TextDecoder().decode(bytes);
|
|
16331
|
+
} catch {
|
|
16332
|
+
return null;
|
|
16333
|
+
}
|
|
16334
|
+
};
|
|
16335
|
+
for (const path of [`/proc/self/status`, `/proc/${ctx.pid}/status`]) {
|
|
16336
|
+
const text = tryRead(path);
|
|
16337
|
+
if (text) return fromProc(text);
|
|
16338
|
+
}
|
|
16339
|
+
const name = ctx.env?.USER || ctx.env?.LOGNAME || "root";
|
|
16340
|
+
const passwd = tryRead("/etc/passwd");
|
|
16341
|
+
if (passwd) {
|
|
16342
|
+
for (const line of passwd.split("\n")) {
|
|
16343
|
+
if (!line || line.startsWith("#")) continue;
|
|
16344
|
+
const [user, , uidStr, gidStr] = line.split(":");
|
|
16345
|
+
if (user !== name) continue;
|
|
16346
|
+
const uid = Number(uidStr) || 0;
|
|
16347
|
+
const gid = Number(gidStr) || 0;
|
|
16348
|
+
const groups = [gid];
|
|
16349
|
+
const group = tryRead("/etc/group");
|
|
16350
|
+
if (group) {
|
|
16351
|
+
for (const gline of group.split("\n")) {
|
|
16352
|
+
if (!gline || gline.startsWith("#")) continue;
|
|
16353
|
+
const [gname, , ggid, members] = gline.split(":");
|
|
16354
|
+
const g = Number(ggid);
|
|
16355
|
+
if (!Number.isFinite(g)) continue;
|
|
16356
|
+
if (gname === name || members && members.split(",").includes(name)) {
|
|
16357
|
+
if (!groups.includes(g)) groups.push(g);
|
|
16358
|
+
}
|
|
16359
|
+
}
|
|
16360
|
+
}
|
|
16361
|
+
return { uid, euid: uid, gid, egid: gid, groups };
|
|
16362
|
+
}
|
|
16363
|
+
}
|
|
16364
|
+
return { uid: 0, euid: 0, gid: 0, egid: 0, groups: [0] };
|
|
16365
|
+
}
|
|
16213
16366
|
var Process = class extends EventEmitter {
|
|
16214
16367
|
constructor({ ctx, argv, nextTick, onExit, handles, Buffer: Buffer2 }) {
|
|
16215
16368
|
super();
|
|
@@ -16325,39 +16478,55 @@ var Process = class extends EventEmitter {
|
|
|
16325
16478
|
cwd() {
|
|
16326
16479
|
return this._cwd;
|
|
16327
16480
|
}
|
|
16328
|
-
/**
|
|
16481
|
+
/** Real kernel credentials (from /proc or /etc/passwd for USER). */
|
|
16482
|
+
_creds() {
|
|
16483
|
+
if (this._credCache) return this._credCache;
|
|
16484
|
+
this._credCache = readProcessCreds(this._ctx);
|
|
16485
|
+
return this._credCache;
|
|
16486
|
+
}
|
|
16329
16487
|
getuid() {
|
|
16330
|
-
return
|
|
16488
|
+
return this._creds().uid;
|
|
16331
16489
|
}
|
|
16332
16490
|
geteuid() {
|
|
16333
|
-
return
|
|
16491
|
+
return this._creds().euid;
|
|
16334
16492
|
}
|
|
16335
16493
|
getgid() {
|
|
16336
|
-
return
|
|
16494
|
+
return this._creds().gid;
|
|
16337
16495
|
}
|
|
16338
16496
|
getegid() {
|
|
16339
|
-
return
|
|
16497
|
+
return this._creds().egid;
|
|
16340
16498
|
}
|
|
16341
16499
|
getgroups() {
|
|
16342
|
-
return
|
|
16500
|
+
return this._creds().groups.slice();
|
|
16343
16501
|
}
|
|
16344
16502
|
/**
|
|
16345
|
-
* Minimal process.kill:
|
|
16346
|
-
*
|
|
16503
|
+
* Minimal process.kill: this process, plus signal 0 as a liveness check.
|
|
16504
|
+
* Unknown / dead pids → ESRCH (Node).
|
|
16347
16505
|
*/
|
|
16348
16506
|
kill(pid, signal = "SIGTERM") {
|
|
16349
16507
|
const target = Number(pid);
|
|
16350
|
-
|
|
16508
|
+
const esrch = () => {
|
|
16351
16509
|
const err = new Error(`kill ESRCH`);
|
|
16352
16510
|
err.code = "ESRCH";
|
|
16353
16511
|
err.errno = -3;
|
|
16354
16512
|
err.syscall = "kill";
|
|
16355
16513
|
throw err;
|
|
16514
|
+
};
|
|
16515
|
+
if (signal === 0 || signal === "0") {
|
|
16516
|
+
if (target !== this.pid) esrch();
|
|
16517
|
+
return true;
|
|
16518
|
+
}
|
|
16519
|
+
if (target !== this.pid) esrch();
|
|
16520
|
+
let name;
|
|
16521
|
+
if (typeof signal === "string") {
|
|
16522
|
+
name = signal.startsWith("SIG") ? signal : `SIG${signal}`;
|
|
16523
|
+
} else if (typeof signal === "number") {
|
|
16524
|
+
name = SIGNAL_BY_NUMBER[signal] ?? "SIGTERM";
|
|
16525
|
+
} else {
|
|
16526
|
+
name = "SIGTERM";
|
|
16356
16527
|
}
|
|
16357
|
-
|
|
16358
|
-
|
|
16359
|
-
const codes = { SIGTERM: 143, SIGINT: 130, SIGHUP: 129, SIGKILL: 137 };
|
|
16360
|
-
this.exit(codes[name] ?? 1);
|
|
16528
|
+
if (SIGNAL_EXIT_CODES[name] != null) {
|
|
16529
|
+
this.exit(SIGNAL_EXIT_CODES[name]);
|
|
16361
16530
|
}
|
|
16362
16531
|
return true;
|
|
16363
16532
|
}
|
package/dist/meta-main.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/runtime/exit.mjs":{"bytes":1670,"imports":[],"format":"esm"},"package.json":{"bytes":2579,"imports":[],"format":"esm","with":{"type":"json"}},"src/jsh/parse-flags.mjs":{"bytes":1829,"imports":[],"format":"esm"},"src/jsh/sliccy/exec.mjs":{"bytes":4790,"imports":[],"format":"esm"},"src/jsh/sliccy/http.mjs":{"bytes":5865,"imports":[],"format":"esm"},"src/jsh/sliccy/pure.mjs":{"bytes":7087,"imports":[],"format":"esm"},"src/jsh/sliccy/index.mjs":{"bytes":2910,"imports":[{"path":"src/jsh/sliccy/exec.mjs","kind":"import-statement","original":"./exec.mjs"},{"path":"src/jsh/sliccy/http.mjs","kind":"import-statement","original":"./http.mjs"},{"path":"src/jsh/sliccy/pure.mjs","kind":"import-statement","original":"./pure.mjs"}],"format":"esm"},"src/jsh/run.mjs":{"bytes":4655,"imports":[{"path":"package.json","kind":"import-statement","original":"../../package.json","with":{"type":"json"}},{"path":"src/jsh/parse-flags.mjs","kind":"import-statement","original":"./parse-flags.mjs"},{"path":"src/jsh/sliccy/index.mjs","kind":"import-statement","original":"./sliccy/index.mjs"}],"format":"esm"},"src/jsh/kernel.mjs":{"bytes":5909,"imports":[{"path":"src/runtime/exit.mjs","kind":"import-statement","original":"../runtime/exit.mjs"},{"path":"src/jsh/run.mjs","kind":"import-statement","original":"./run.mjs"}],"format":"esm"},"src/runtime/async-handles.mjs":{"bytes":2272,"imports":[],"format":"esm"},"src/runtime/buffer.mjs":{"bytes":37245,"imports":[],"format":"esm"},"node_modules/node-inspect-extracted/dist/inspect.js":{"bytes":51340,"imports":[],"format":"cjs"},"node_modules/node-inspect-extracted/index.mjs":{"bytes":380,"imports":[{"path":"node_modules/node-inspect-extracted/dist/inspect.js","kind":"import-statement","original":"./dist/inspect.js"}],"format":"esm"},"src/runtime/builtins/util.mjs":{"bytes":4208,"imports":[{"path":"node_modules/node-inspect-extracted/index.mjs","kind":"import-statement","original":"node-inspect-extracted"}],"format":"esm"},"node_modules/acorn/dist/acorn.mjs":{"bytes":234658,"imports":[],"format":"esm"},"src/runtime/esm/transform.mjs":{"bytes":25854,"imports":[{"path":"node_modules/acorn/dist/acorn.mjs","kind":"import-statement","original":"acorn"}],"format":"esm"},"src/runtime/path.mjs":{"bytes":4249,"imports":[],"format":"esm"},"src/runtime/builtins/assert.mjs":{"bytes":20298,"imports":[{"path":"node_modules/node-inspect-extracted/index.mjs","kind":"import-statement","original":"node-inspect-extracted"}],"format":"esm"},"src/runtime/builtins/events.mjs":{"bytes":2406,"imports":[],"format":"esm"},"src/runtime/builtins/child-process.mjs":{"bytes":13534,"imports":[{"path":"src/runtime/async-handles.mjs","kind":"import-statement","original":"../async-handles.mjs"},{"path":"src/runtime/builtins/events.mjs","kind":"import-statement","original":"./events.mjs"}],"format":"esm"},"src/runtime/builtins/fs.mjs":{"bytes":35102,"imports":[{"path":"src/runtime/async-handles.mjs","kind":"import-statement","original":"../async-handles.mjs"}],"format":"esm"},"src/runtime/builtins/http.mjs":{"bytes":30054,"imports":[{"path":"src/runtime/builtins/events.mjs","kind":"import-statement","original":"./events.mjs"}],"format":"esm"},"src/runtime/builtins/https.mjs":{"bytes":8217,"imports":[{"path":"src/runtime/async-handles.mjs","kind":"import-statement","original":"../async-handles.mjs"},{"path":"src/runtime/builtins/events.mjs","kind":"import-statement","original":"./events.mjs"}],"format":"esm"},"src/runtime/builtins/net.mjs":{"bytes":17353,"imports":[{"path":"src/runtime/async-handles.mjs","kind":"import-statement","original":"../async-handles.mjs"},{"path":"src/runtime/builtins/events.mjs","kind":"import-statement","original":"./events.mjs"}],"format":"esm"},"src/runtime/builtins/os.mjs":{"bytes":719,"imports":[],"format":"esm"},"src/runtime/builtins/querystring.mjs":{"bytes":1235,"imports":[],"format":"esm"},"src/runtime/vendor-load.mjs":{"bytes":1636,"imports":[],"format":"esm"},"src/runtime/builtins/stream.mjs":{"bytes":1263,"imports":[{"path":"src/runtime/async-handles.mjs","kind":"import-statement","original":"../async-handles.mjs"},{"path":"src/runtime/vendor-load.mjs","kind":"import-statement","original":"../vendor-load.mjs"}],"format":"esm"},"src/runtime/builtins/string-decoder.mjs":{"bytes":3885,"imports":[{"path":"src/runtime/vendor-load.mjs","kind":"import-statement","original":"../vendor-load.mjs"}],"format":"esm"},"src/runtime/builtins/timers-module.mjs":{"bytes":1138,"imports":[{"path":"src/runtime/async-handles.mjs","kind":"import-statement","original":"../async-handles.mjs"}],"format":"esm"},"src/runtime/builtins/url.mjs":{"bytes":1774,"imports":[],"format":"esm"},"src/runtime/cjs/builtins.mjs":{"bytes":4969,"imports":[{"path":"src/runtime/builtins/assert.mjs","kind":"import-statement","original":"../builtins/assert.mjs"},{"path":"src/runtime/builtins/child-process.mjs","kind":"import-statement","original":"../builtins/child-process.mjs"},{"path":"src/runtime/builtins/events.mjs","kind":"import-statement","original":"../builtins/events.mjs"},{"path":"src/runtime/builtins/fs.mjs","kind":"import-statement","original":"../builtins/fs.mjs"},{"path":"src/runtime/builtins/http.mjs","kind":"import-statement","original":"../builtins/http.mjs"},{"path":"src/runtime/builtins/https.mjs","kind":"import-statement","original":"../builtins/https.mjs"},{"path":"src/runtime/builtins/net.mjs","kind":"import-statement","original":"../builtins/net.mjs"},{"path":"src/runtime/builtins/os.mjs","kind":"import-statement","original":"../builtins/os.mjs"},{"path":"src/runtime/builtins/querystring.mjs","kind":"import-statement","original":"../builtins/querystring.mjs"},{"path":"src/runtime/builtins/stream.mjs","kind":"import-statement","original":"../builtins/stream.mjs"},{"path":"src/runtime/builtins/string-decoder.mjs","kind":"import-statement","original":"../builtins/string-decoder.mjs"},{"path":"src/runtime/builtins/timers-module.mjs","kind":"import-statement","original":"../builtins/timers-module.mjs"},{"path":"src/runtime/builtins/url.mjs","kind":"import-statement","original":"../builtins/url.mjs"},{"path":"src/runtime/builtins/util.mjs","kind":"import-statement","original":"../builtins/util.mjs"}],"format":"esm"},"src/runtime/cjs/errors.mjs":{"bytes":882,"imports":[],"format":"esm"},"src/runtime/cjs/resolve.mjs":{"bytes":9966,"imports":[{"path":"src/runtime/cjs/errors.mjs","kind":"import-statement","original":"./errors.mjs"}],"format":"esm"},"src/runtime/cjs/loader.mjs":{"bytes":13441,"imports":[{"path":"src/runtime/esm/transform.mjs","kind":"import-statement","original":"../esm/transform.mjs"},{"path":"src/runtime/path.mjs","kind":"import-statement","original":"../path.mjs"},{"path":"src/runtime/cjs/builtins.mjs","kind":"import-statement","original":"./builtins.mjs"},{"path":"src/runtime/cjs/resolve.mjs","kind":"import-statement","original":"./resolve.mjs"}],"format":"esm"},"src/runtime/cli.mjs":{"bytes":2291,"imports":[],"format":"esm"},"src/runtime/console.mjs":{"bytes":4413,"imports":[],"format":"esm"},"src/runtime/esm/loader.mjs":{"bytes":13249,"imports":[{"path":"src/runtime/path.mjs","kind":"import-statement","original":"../path.mjs"},{"path":"src/runtime/cjs/resolve.mjs","kind":"import-statement","original":"../cjs/resolve.mjs"},{"path":"src/runtime/esm/transform.mjs","kind":"import-statement","original":"./transform.mjs"}],"format":"esm"},"src/runtime/stack.mjs":{"bytes":8404,"imports":[],"format":"esm"},"src/runtime/errors-format.mjs":{"bytes":11779,"imports":[{"path":"src/runtime/stack.mjs","kind":"import-statement","original":"./stack.mjs"}],"format":"esm"},"src/runtime/handles.mjs":{"bytes":800,"imports":[],"format":"esm"},"src/runtime/next-tick.mjs":{"bytes":1268,"imports":[],"format":"esm"},"src/runtime/process.mjs":{"bytes":12375,"imports":[{"path":"src/runtime/builtins/events.mjs","kind":"import-statement","original":"./builtins/events.mjs"},{"path":"src/runtime/exit.mjs","kind":"import-statement","original":"./exit.mjs"}],"format":"esm"},"src/runtime/timers.mjs":{"bytes":3775,"imports":[],"format":"esm"},"src/runtime/web/fetch.mjs":{"bytes":443,"imports":[],"format":"esm"},"src/runtime/web/websocket.mjs":{"bytes":9530,"imports":[{"path":"src/runtime/exit.mjs","kind":"import-statement","original":"../exit.mjs"}],"format":"esm"},"src/runtime/run.mjs":{"bytes":17936,"imports":[{"path":"src/jsh/kernel.mjs","kind":"import-statement","original":"../jsh/kernel.mjs"},{"path":"src/runtime/async-handles.mjs","kind":"import-statement","original":"./async-handles.mjs"},{"path":"src/runtime/buffer.mjs","kind":"import-statement","original":"./buffer.mjs"},{"path":"src/runtime/builtins/util.mjs","kind":"import-statement","original":"./builtins/util.mjs"},{"path":"src/runtime/cjs/loader.mjs","kind":"import-statement","original":"./cjs/loader.mjs"},{"path":"src/runtime/cli.mjs","kind":"import-statement","original":"./cli.mjs"},{"path":"src/runtime/console.mjs","kind":"import-statement","original":"./console.mjs"},{"path":"src/runtime/esm/loader.mjs","kind":"import-statement","original":"./esm/loader.mjs"},{"path":"src/runtime/esm/transform.mjs","kind":"import-statement","original":"./esm/transform.mjs"},{"path":"src/runtime/errors-format.mjs","kind":"import-statement","original":"./errors-format.mjs"},{"path":"src/runtime/exit.mjs","kind":"import-statement","original":"./exit.mjs"},{"path":"src/runtime/handles.mjs","kind":"import-statement","original":"./handles.mjs"},{"path":"src/runtime/next-tick.mjs","kind":"import-statement","original":"./next-tick.mjs"},{"path":"src/runtime/process.mjs","kind":"import-statement","original":"./process.mjs"},{"path":"src/runtime/stack.mjs","kind":"import-statement","original":"./stack.mjs"},{"path":"src/runtime/timers.mjs","kind":"import-statement","original":"./timers.mjs"},{"path":"src/runtime/web/fetch.mjs","kind":"import-statement","original":"./web/fetch.mjs"},{"path":"src/runtime/web/websocket.mjs","kind":"import-statement","original":"./web/websocket.mjs"}],"format":"esm"},"src/node.mjs":{"bytes":233,"imports":[{"path":"src/runtime/run.mjs","kind":"import-statement","original":"./runtime/run.mjs"}],"format":"esm"},"src/jsh.mjs":{"bytes":1273,"imports":[{"path":"src/jsh/kernel.mjs","kind":"import-statement","original":"./jsh/kernel.mjs"},{"path":"src/jsh/run.mjs","kind":"import-statement","original":"./jsh/run.mjs"},{"path":"src/runtime/run.mjs","kind":"import-statement","original":"./runtime/run.mjs"}],"format":"esm"}},"outputs":{"dist/node.mjs":{"imports":[],"exports":["default"],"entryPoint":"src/node.mjs","inputs":{"node_modules/node-inspect-extracted/dist/inspect.js":{"bytesInOutput":86401},"src/runtime/exit.mjs":{"bytesInOutput":1573},"package.json":{"bytesInOutput":2504},"src/jsh/parse-flags.mjs":{"bytesInOutput":1558},"src/jsh/sliccy/exec.mjs":{"bytesInOutput":4077},"src/jsh/sliccy/http.mjs":{"bytesInOutput":5497},"src/jsh/sliccy/pure.mjs":{"bytesInOutput":6246},"src/jsh/sliccy/index.mjs":{"bytesInOutput":2229},"src/jsh/run.mjs":{"bytesInOutput":2930},"src/jsh/kernel.mjs":{"bytesInOutput":4606},"src/runtime/async-handles.mjs":{"bytesInOutput":1156},"src/runtime/buffer.mjs":{"bytesInOutput":36834},"node_modules/node-inspect-extracted/index.mjs":{"bytesInOutput":387},"src/runtime/builtins/util.mjs":{"bytesInOutput":3726},"node_modules/acorn/dist/acorn.mjs":{"bytesInOutput":203908},"src/runtime/esm/transform.mjs":{"bytesInOutput":20720},"src/runtime/path.mjs":{"bytesInOutput":4196},"src/runtime/builtins/assert.mjs":{"bytesInOutput":19383},"src/runtime/builtins/events.mjs":{"bytesInOutput":2336},"src/runtime/builtins/child-process.mjs":{"bytesInOutput":12707},"src/runtime/builtins/fs.mjs":{"bytesInOutput":33539},"src/runtime/builtins/http.mjs":{"bytesInOutput":27190},"src/runtime/builtins/https.mjs":{"bytesInOutput":7341},"src/runtime/builtins/net.mjs":{"bytesInOutput":14529},"src/runtime/builtins/os.mjs":{"bytesInOutput":648},"src/runtime/builtins/querystring.mjs":{"bytesInOutput":1197},"src/runtime/vendor-load.mjs":{"bytesInOutput":1158},"src/runtime/builtins/stream.mjs":{"bytesInOutput":1116},"src/runtime/builtins/string-decoder.mjs":{"bytesInOutput":3195},"src/runtime/builtins/timers-module.mjs":{"bytesInOutput":969},"src/runtime/builtins/url.mjs":{"bytesInOutput":1697},"src/runtime/cjs/builtins.mjs":{"bytesInOutput":4158},"src/runtime/cjs/errors.mjs":{"bytesInOutput":574},"src/runtime/cjs/resolve.mjs":{"bytesInOutput":8866},"src/runtime/cjs/loader.mjs":{"bytesInOutput":11203},"src/runtime/cli.mjs":{"bytesInOutput":2165},"src/runtime/console.mjs":{"bytesInOutput":4414},"src/runtime/esm/loader.mjs":{"bytesInOutput":11287},"src/runtime/stack.mjs":{"bytesInOutput":6887},"src/runtime/errors-format.mjs":{"bytesInOutput":9795},"src/runtime/handles.mjs":{"bytesInOutput":688},"src/runtime/next-tick.mjs":{"bytesInOutput":900},"src/runtime/process.mjs":{"bytesInOutput":11718},"src/runtime/timers.mjs":{"bytesInOutput":3529},"src/runtime/web/fetch.mjs":{"bytesInOutput":358},"src/runtime/web/websocket.mjs":{"bytesInOutput":8204},"src/runtime/run.mjs":{"bytesInOutput":13844},"src/node.mjs":{"bytesInOutput":52}},"bytes":617119},"dist/jsh.mjs":{"imports":[],"exports":["default"],"entryPoint":"src/jsh.mjs","inputs":{"node_modules/node-inspect-extracted/dist/inspect.js":{"bytesInOutput":86401},"src/runtime/exit.mjs":{"bytesInOutput":1573},"package.json":{"bytesInOutput":2504},"src/jsh/parse-flags.mjs":{"bytesInOutput":1558},"src/jsh/sliccy/exec.mjs":{"bytesInOutput":4077},"src/jsh/sliccy/http.mjs":{"bytesInOutput":5497},"src/jsh/sliccy/pure.mjs":{"bytesInOutput":6246},"src/jsh/sliccy/index.mjs":{"bytesInOutput":2229},"src/jsh/run.mjs":{"bytesInOutput":2930},"src/jsh/kernel.mjs":{"bytesInOutput":4606},"src/runtime/async-handles.mjs":{"bytesInOutput":1156},"src/runtime/buffer.mjs":{"bytesInOutput":36834},"node_modules/node-inspect-extracted/index.mjs":{"bytesInOutput":387},"src/runtime/builtins/util.mjs":{"bytesInOutput":3726},"node_modules/acorn/dist/acorn.mjs":{"bytesInOutput":203908},"src/runtime/esm/transform.mjs":{"bytesInOutput":20720},"src/runtime/path.mjs":{"bytesInOutput":4196},"src/runtime/builtins/assert.mjs":{"bytesInOutput":19383},"src/runtime/builtins/events.mjs":{"bytesInOutput":2336},"src/runtime/builtins/child-process.mjs":{"bytesInOutput":12707},"src/runtime/builtins/fs.mjs":{"bytesInOutput":33539},"src/runtime/builtins/http.mjs":{"bytesInOutput":27190},"src/runtime/builtins/https.mjs":{"bytesInOutput":7341},"src/runtime/builtins/net.mjs":{"bytesInOutput":14529},"src/runtime/builtins/os.mjs":{"bytesInOutput":648},"src/runtime/builtins/querystring.mjs":{"bytesInOutput":1197},"src/runtime/vendor-load.mjs":{"bytesInOutput":1158},"src/runtime/builtins/stream.mjs":{"bytesInOutput":1116},"src/runtime/builtins/string-decoder.mjs":{"bytesInOutput":3195},"src/runtime/builtins/timers-module.mjs":{"bytesInOutput":969},"src/runtime/builtins/url.mjs":{"bytesInOutput":1697},"src/runtime/cjs/builtins.mjs":{"bytesInOutput":4158},"src/runtime/cjs/errors.mjs":{"bytesInOutput":574},"src/runtime/cjs/resolve.mjs":{"bytesInOutput":8866},"src/runtime/cjs/loader.mjs":{"bytesInOutput":11203},"src/runtime/cli.mjs":{"bytesInOutput":2165},"src/runtime/console.mjs":{"bytesInOutput":4414},"src/runtime/esm/loader.mjs":{"bytesInOutput":11287},"src/runtime/stack.mjs":{"bytesInOutput":6887},"src/runtime/errors-format.mjs":{"bytesInOutput":9795},"src/runtime/handles.mjs":{"bytesInOutput":688},"src/runtime/next-tick.mjs":{"bytesInOutput":900},"src/runtime/process.mjs":{"bytesInOutput":11718},"src/runtime/timers.mjs":{"bytesInOutput":3529},"src/runtime/web/fetch.mjs":{"bytesInOutput":358},"src/runtime/web/websocket.mjs":{"bytesInOutput":8204},"src/runtime/run.mjs":{"bytesInOutput":13844},"src/jsh.mjs":{"bytesInOutput":761}},"bytes":617827}}}
|
|
1
|
+
{"inputs":{"src/runtime/exit.mjs":{"bytes":1670,"imports":[],"format":"esm"},"package.json":{"bytes":2579,"imports":[],"format":"esm","with":{"type":"json"}},"src/jsh/parse-flags.mjs":{"bytes":1829,"imports":[],"format":"esm"},"src/jsh/sliccy/exec.mjs":{"bytes":4790,"imports":[],"format":"esm"},"src/jsh/sliccy/http.mjs":{"bytes":5865,"imports":[],"format":"esm"},"src/jsh/sliccy/pure.mjs":{"bytes":7087,"imports":[],"format":"esm"},"src/jsh/sliccy/index.mjs":{"bytes":2910,"imports":[{"path":"src/jsh/sliccy/exec.mjs","kind":"import-statement","original":"./exec.mjs"},{"path":"src/jsh/sliccy/http.mjs","kind":"import-statement","original":"./http.mjs"},{"path":"src/jsh/sliccy/pure.mjs","kind":"import-statement","original":"./pure.mjs"}],"format":"esm"},"src/jsh/run.mjs":{"bytes":4655,"imports":[{"path":"package.json","kind":"import-statement","original":"../../package.json","with":{"type":"json"}},{"path":"src/jsh/parse-flags.mjs","kind":"import-statement","original":"./parse-flags.mjs"},{"path":"src/jsh/sliccy/index.mjs","kind":"import-statement","original":"./sliccy/index.mjs"}],"format":"esm"},"src/jsh/kernel.mjs":{"bytes":5909,"imports":[{"path":"src/runtime/exit.mjs","kind":"import-statement","original":"../runtime/exit.mjs"},{"path":"src/jsh/run.mjs","kind":"import-statement","original":"./run.mjs"}],"format":"esm"},"src/runtime/async-handles.mjs":{"bytes":2272,"imports":[],"format":"esm"},"src/runtime/buffer.mjs":{"bytes":37245,"imports":[],"format":"esm"},"node_modules/node-inspect-extracted/dist/inspect.js":{"bytes":51340,"imports":[],"format":"cjs"},"node_modules/node-inspect-extracted/index.mjs":{"bytes":380,"imports":[{"path":"node_modules/node-inspect-extracted/dist/inspect.js","kind":"import-statement","original":"./dist/inspect.js"}],"format":"esm"},"src/runtime/builtins/util.mjs":{"bytes":4208,"imports":[{"path":"node_modules/node-inspect-extracted/index.mjs","kind":"import-statement","original":"node-inspect-extracted"}],"format":"esm"},"node_modules/acorn/dist/acorn.mjs":{"bytes":234658,"imports":[],"format":"esm"},"src/runtime/esm/transform.mjs":{"bytes":25854,"imports":[{"path":"node_modules/acorn/dist/acorn.mjs","kind":"import-statement","original":"acorn"}],"format":"esm"},"src/runtime/path.mjs":{"bytes":4249,"imports":[],"format":"esm"},"src/runtime/builtins/assert.mjs":{"bytes":20298,"imports":[{"path":"node_modules/node-inspect-extracted/index.mjs","kind":"import-statement","original":"node-inspect-extracted"}],"format":"esm"},"src/runtime/builtins/events.mjs":{"bytes":2406,"imports":[],"format":"esm"},"src/runtime/builtins/child-process.mjs":{"bytes":16731,"imports":[{"path":"src/runtime/async-handles.mjs","kind":"import-statement","original":"../async-handles.mjs"},{"path":"src/runtime/builtins/events.mjs","kind":"import-statement","original":"./events.mjs"}],"format":"esm"},"src/runtime/builtins/fs.mjs":{"bytes":35102,"imports":[{"path":"src/runtime/async-handles.mjs","kind":"import-statement","original":"../async-handles.mjs"}],"format":"esm"},"src/runtime/builtins/http.mjs":{"bytes":30054,"imports":[{"path":"src/runtime/builtins/events.mjs","kind":"import-statement","original":"./events.mjs"}],"format":"esm"},"src/runtime/builtins/https.mjs":{"bytes":8217,"imports":[{"path":"src/runtime/async-handles.mjs","kind":"import-statement","original":"../async-handles.mjs"},{"path":"src/runtime/builtins/events.mjs","kind":"import-statement","original":"./events.mjs"}],"format":"esm"},"src/runtime/builtins/net.mjs":{"bytes":17353,"imports":[{"path":"src/runtime/async-handles.mjs","kind":"import-statement","original":"../async-handles.mjs"},{"path":"src/runtime/builtins/events.mjs","kind":"import-statement","original":"./events.mjs"}],"format":"esm"},"src/runtime/builtins/os.mjs":{"bytes":719,"imports":[],"format":"esm"},"src/runtime/builtins/querystring.mjs":{"bytes":1235,"imports":[],"format":"esm"},"src/runtime/vendor-load.mjs":{"bytes":1636,"imports":[],"format":"esm"},"src/runtime/builtins/stream.mjs":{"bytes":1263,"imports":[{"path":"src/runtime/async-handles.mjs","kind":"import-statement","original":"../async-handles.mjs"},{"path":"src/runtime/vendor-load.mjs","kind":"import-statement","original":"../vendor-load.mjs"}],"format":"esm"},"src/runtime/builtins/string-decoder.mjs":{"bytes":3885,"imports":[{"path":"src/runtime/vendor-load.mjs","kind":"import-statement","original":"../vendor-load.mjs"}],"format":"esm"},"src/runtime/builtins/timers-module.mjs":{"bytes":1138,"imports":[{"path":"src/runtime/async-handles.mjs","kind":"import-statement","original":"../async-handles.mjs"}],"format":"esm"},"src/runtime/builtins/url.mjs":{"bytes":1774,"imports":[],"format":"esm"},"src/runtime/cjs/builtins.mjs":{"bytes":4969,"imports":[{"path":"src/runtime/builtins/assert.mjs","kind":"import-statement","original":"../builtins/assert.mjs"},{"path":"src/runtime/builtins/child-process.mjs","kind":"import-statement","original":"../builtins/child-process.mjs"},{"path":"src/runtime/builtins/events.mjs","kind":"import-statement","original":"../builtins/events.mjs"},{"path":"src/runtime/builtins/fs.mjs","kind":"import-statement","original":"../builtins/fs.mjs"},{"path":"src/runtime/builtins/http.mjs","kind":"import-statement","original":"../builtins/http.mjs"},{"path":"src/runtime/builtins/https.mjs","kind":"import-statement","original":"../builtins/https.mjs"},{"path":"src/runtime/builtins/net.mjs","kind":"import-statement","original":"../builtins/net.mjs"},{"path":"src/runtime/builtins/os.mjs","kind":"import-statement","original":"../builtins/os.mjs"},{"path":"src/runtime/builtins/querystring.mjs","kind":"import-statement","original":"../builtins/querystring.mjs"},{"path":"src/runtime/builtins/stream.mjs","kind":"import-statement","original":"../builtins/stream.mjs"},{"path":"src/runtime/builtins/string-decoder.mjs","kind":"import-statement","original":"../builtins/string-decoder.mjs"},{"path":"src/runtime/builtins/timers-module.mjs","kind":"import-statement","original":"../builtins/timers-module.mjs"},{"path":"src/runtime/builtins/url.mjs","kind":"import-statement","original":"../builtins/url.mjs"},{"path":"src/runtime/builtins/util.mjs","kind":"import-statement","original":"../builtins/util.mjs"}],"format":"esm"},"src/runtime/cjs/errors.mjs":{"bytes":882,"imports":[],"format":"esm"},"src/runtime/cjs/resolve.mjs":{"bytes":9966,"imports":[{"path":"src/runtime/cjs/errors.mjs","kind":"import-statement","original":"./errors.mjs"}],"format":"esm"},"src/runtime/cjs/loader.mjs":{"bytes":13441,"imports":[{"path":"src/runtime/esm/transform.mjs","kind":"import-statement","original":"../esm/transform.mjs"},{"path":"src/runtime/path.mjs","kind":"import-statement","original":"../path.mjs"},{"path":"src/runtime/cjs/builtins.mjs","kind":"import-statement","original":"./builtins.mjs"},{"path":"src/runtime/cjs/resolve.mjs","kind":"import-statement","original":"./resolve.mjs"}],"format":"esm"},"src/runtime/cli.mjs":{"bytes":2291,"imports":[],"format":"esm"},"src/runtime/console.mjs":{"bytes":4413,"imports":[],"format":"esm"},"src/runtime/esm/loader.mjs":{"bytes":13249,"imports":[{"path":"src/runtime/path.mjs","kind":"import-statement","original":"../path.mjs"},{"path":"src/runtime/cjs/resolve.mjs","kind":"import-statement","original":"../cjs/resolve.mjs"},{"path":"src/runtime/esm/transform.mjs","kind":"import-statement","original":"./transform.mjs"}],"format":"esm"},"src/runtime/stack.mjs":{"bytes":8404,"imports":[],"format":"esm"},"src/runtime/errors-format.mjs":{"bytes":11779,"imports":[{"path":"src/runtime/stack.mjs","kind":"import-statement","original":"./stack.mjs"}],"format":"esm"},"src/runtime/handles.mjs":{"bytes":800,"imports":[],"format":"esm"},"src/runtime/next-tick.mjs":{"bytes":1268,"imports":[],"format":"esm"},"src/runtime/process.mjs":{"bytes":15294,"imports":[{"path":"src/runtime/builtins/events.mjs","kind":"import-statement","original":"./builtins/events.mjs"},{"path":"src/runtime/exit.mjs","kind":"import-statement","original":"./exit.mjs"}],"format":"esm"},"src/runtime/timers.mjs":{"bytes":3775,"imports":[],"format":"esm"},"src/runtime/web/fetch.mjs":{"bytes":443,"imports":[],"format":"esm"},"src/runtime/web/websocket.mjs":{"bytes":9530,"imports":[{"path":"src/runtime/exit.mjs","kind":"import-statement","original":"../exit.mjs"}],"format":"esm"},"src/runtime/run.mjs":{"bytes":17936,"imports":[{"path":"src/jsh/kernel.mjs","kind":"import-statement","original":"../jsh/kernel.mjs"},{"path":"src/runtime/async-handles.mjs","kind":"import-statement","original":"./async-handles.mjs"},{"path":"src/runtime/buffer.mjs","kind":"import-statement","original":"./buffer.mjs"},{"path":"src/runtime/builtins/util.mjs","kind":"import-statement","original":"./builtins/util.mjs"},{"path":"src/runtime/cjs/loader.mjs","kind":"import-statement","original":"./cjs/loader.mjs"},{"path":"src/runtime/cli.mjs","kind":"import-statement","original":"./cli.mjs"},{"path":"src/runtime/console.mjs","kind":"import-statement","original":"./console.mjs"},{"path":"src/runtime/esm/loader.mjs","kind":"import-statement","original":"./esm/loader.mjs"},{"path":"src/runtime/esm/transform.mjs","kind":"import-statement","original":"./esm/transform.mjs"},{"path":"src/runtime/errors-format.mjs","kind":"import-statement","original":"./errors-format.mjs"},{"path":"src/runtime/exit.mjs","kind":"import-statement","original":"./exit.mjs"},{"path":"src/runtime/handles.mjs","kind":"import-statement","original":"./handles.mjs"},{"path":"src/runtime/next-tick.mjs","kind":"import-statement","original":"./next-tick.mjs"},{"path":"src/runtime/process.mjs","kind":"import-statement","original":"./process.mjs"},{"path":"src/runtime/stack.mjs","kind":"import-statement","original":"./stack.mjs"},{"path":"src/runtime/timers.mjs","kind":"import-statement","original":"./timers.mjs"},{"path":"src/runtime/web/fetch.mjs","kind":"import-statement","original":"./web/fetch.mjs"},{"path":"src/runtime/web/websocket.mjs","kind":"import-statement","original":"./web/websocket.mjs"}],"format":"esm"},"src/node.mjs":{"bytes":233,"imports":[{"path":"src/runtime/run.mjs","kind":"import-statement","original":"./runtime/run.mjs"}],"format":"esm"},"src/jsh.mjs":{"bytes":1273,"imports":[{"path":"src/jsh/kernel.mjs","kind":"import-statement","original":"./jsh/kernel.mjs"},{"path":"src/jsh/run.mjs","kind":"import-statement","original":"./jsh/run.mjs"},{"path":"src/runtime/run.mjs","kind":"import-statement","original":"./runtime/run.mjs"}],"format":"esm"}},"outputs":{"dist/node.mjs":{"imports":[],"exports":["default"],"entryPoint":"src/node.mjs","inputs":{"node_modules/node-inspect-extracted/dist/inspect.js":{"bytesInOutput":86401},"src/runtime/exit.mjs":{"bytesInOutput":1573},"package.json":{"bytesInOutput":2504},"src/jsh/parse-flags.mjs":{"bytesInOutput":1558},"src/jsh/sliccy/exec.mjs":{"bytesInOutput":4077},"src/jsh/sliccy/http.mjs":{"bytesInOutput":5497},"src/jsh/sliccy/pure.mjs":{"bytesInOutput":6246},"src/jsh/sliccy/index.mjs":{"bytesInOutput":2229},"src/jsh/run.mjs":{"bytesInOutput":2930},"src/jsh/kernel.mjs":{"bytesInOutput":4606},"src/runtime/async-handles.mjs":{"bytesInOutput":1156},"src/runtime/buffer.mjs":{"bytesInOutput":36834},"node_modules/node-inspect-extracted/index.mjs":{"bytesInOutput":387},"src/runtime/builtins/util.mjs":{"bytesInOutput":3726},"node_modules/acorn/dist/acorn.mjs":{"bytesInOutput":203908},"src/runtime/esm/transform.mjs":{"bytesInOutput":20720},"src/runtime/path.mjs":{"bytesInOutput":4196},"src/runtime/builtins/assert.mjs":{"bytesInOutput":19383},"src/runtime/builtins/events.mjs":{"bytesInOutput":2336},"src/runtime/builtins/child-process.mjs":{"bytesInOutput":15066},"src/runtime/builtins/fs.mjs":{"bytesInOutput":33539},"src/runtime/builtins/http.mjs":{"bytesInOutput":27190},"src/runtime/builtins/https.mjs":{"bytesInOutput":7341},"src/runtime/builtins/net.mjs":{"bytesInOutput":14529},"src/runtime/builtins/os.mjs":{"bytesInOutput":648},"src/runtime/builtins/querystring.mjs":{"bytesInOutput":1197},"src/runtime/vendor-load.mjs":{"bytesInOutput":1158},"src/runtime/builtins/stream.mjs":{"bytesInOutput":1116},"src/runtime/builtins/string-decoder.mjs":{"bytesInOutput":3195},"src/runtime/builtins/timers-module.mjs":{"bytesInOutput":969},"src/runtime/builtins/url.mjs":{"bytesInOutput":1697},"src/runtime/cjs/builtins.mjs":{"bytesInOutput":4158},"src/runtime/cjs/errors.mjs":{"bytesInOutput":574},"src/runtime/cjs/resolve.mjs":{"bytesInOutput":8866},"src/runtime/cjs/loader.mjs":{"bytesInOutput":11203},"src/runtime/cli.mjs":{"bytesInOutput":2165},"src/runtime/console.mjs":{"bytesInOutput":4414},"src/runtime/esm/loader.mjs":{"bytesInOutput":11287},"src/runtime/stack.mjs":{"bytesInOutput":6887},"src/runtime/errors-format.mjs":{"bytesInOutput":9795},"src/runtime/handles.mjs":{"bytesInOutput":688},"src/runtime/next-tick.mjs":{"bytesInOutput":900},"src/runtime/process.mjs":{"bytesInOutput":14431},"src/runtime/timers.mjs":{"bytesInOutput":3529},"src/runtime/web/fetch.mjs":{"bytesInOutput":358},"src/runtime/web/websocket.mjs":{"bytesInOutput":8204},"src/runtime/run.mjs":{"bytesInOutput":13844},"src/node.mjs":{"bytesInOutput":52}},"bytes":622191},"dist/jsh.mjs":{"imports":[],"exports":["default"],"entryPoint":"src/jsh.mjs","inputs":{"node_modules/node-inspect-extracted/dist/inspect.js":{"bytesInOutput":86401},"src/runtime/exit.mjs":{"bytesInOutput":1573},"package.json":{"bytesInOutput":2504},"src/jsh/parse-flags.mjs":{"bytesInOutput":1558},"src/jsh/sliccy/exec.mjs":{"bytesInOutput":4077},"src/jsh/sliccy/http.mjs":{"bytesInOutput":5497},"src/jsh/sliccy/pure.mjs":{"bytesInOutput":6246},"src/jsh/sliccy/index.mjs":{"bytesInOutput":2229},"src/jsh/run.mjs":{"bytesInOutput":2930},"src/jsh/kernel.mjs":{"bytesInOutput":4606},"src/runtime/async-handles.mjs":{"bytesInOutput":1156},"src/runtime/buffer.mjs":{"bytesInOutput":36834},"node_modules/node-inspect-extracted/index.mjs":{"bytesInOutput":387},"src/runtime/builtins/util.mjs":{"bytesInOutput":3726},"node_modules/acorn/dist/acorn.mjs":{"bytesInOutput":203908},"src/runtime/esm/transform.mjs":{"bytesInOutput":20720},"src/runtime/path.mjs":{"bytesInOutput":4196},"src/runtime/builtins/assert.mjs":{"bytesInOutput":19383},"src/runtime/builtins/events.mjs":{"bytesInOutput":2336},"src/runtime/builtins/child-process.mjs":{"bytesInOutput":15066},"src/runtime/builtins/fs.mjs":{"bytesInOutput":33539},"src/runtime/builtins/http.mjs":{"bytesInOutput":27190},"src/runtime/builtins/https.mjs":{"bytesInOutput":7341},"src/runtime/builtins/net.mjs":{"bytesInOutput":14529},"src/runtime/builtins/os.mjs":{"bytesInOutput":648},"src/runtime/builtins/querystring.mjs":{"bytesInOutput":1197},"src/runtime/vendor-load.mjs":{"bytesInOutput":1158},"src/runtime/builtins/stream.mjs":{"bytesInOutput":1116},"src/runtime/builtins/string-decoder.mjs":{"bytesInOutput":3195},"src/runtime/builtins/timers-module.mjs":{"bytesInOutput":969},"src/runtime/builtins/url.mjs":{"bytesInOutput":1697},"src/runtime/cjs/builtins.mjs":{"bytesInOutput":4158},"src/runtime/cjs/errors.mjs":{"bytesInOutput":574},"src/runtime/cjs/resolve.mjs":{"bytesInOutput":8866},"src/runtime/cjs/loader.mjs":{"bytesInOutput":11203},"src/runtime/cli.mjs":{"bytesInOutput":2165},"src/runtime/console.mjs":{"bytesInOutput":4414},"src/runtime/esm/loader.mjs":{"bytesInOutput":11287},"src/runtime/stack.mjs":{"bytesInOutput":6887},"src/runtime/errors-format.mjs":{"bytesInOutput":9795},"src/runtime/handles.mjs":{"bytesInOutput":688},"src/runtime/next-tick.mjs":{"bytesInOutput":900},"src/runtime/process.mjs":{"bytesInOutput":14431},"src/runtime/timers.mjs":{"bytesInOutput":3529},"src/runtime/web/fetch.mjs":{"bytesInOutput":358},"src/runtime/web/websocket.mjs":{"bytesInOutput":8204},"src/runtime/run.mjs":{"bytesInOutput":13844},"src/jsh.mjs":{"bytesInOutput":761}},"bytes":622899}}}
|
package/dist/node.mjs
CHANGED
|
@@ -1585,7 +1585,7 @@ function assignProcessExitCode(value) {
|
|
|
1585
1585
|
// package.json
|
|
1586
1586
|
var package_default = {
|
|
1587
1587
|
name: "@ai-ecoverse/slicc-jsh",
|
|
1588
|
-
version: "0.3.
|
|
1588
|
+
version: "0.3.2",
|
|
1589
1589
|
description: "Node.js-compatible runtime for slicc-kernel: the node and jsh commands (abi: js)",
|
|
1590
1590
|
type: "module",
|
|
1591
1591
|
license: "Apache-2.0",
|
|
@@ -10818,6 +10818,9 @@ function notSupported(name) {
|
|
|
10818
10818
|
err.code = "ERR_NOT_SUPPORTED";
|
|
10819
10819
|
throw err;
|
|
10820
10820
|
}
|
|
10821
|
+
function isExitError(err) {
|
|
10822
|
+
return err?.name === "NodeExitError";
|
|
10823
|
+
}
|
|
10821
10824
|
function normalizeArgs(file, args, options, callback) {
|
|
10822
10825
|
if (typeof args === "function") {
|
|
10823
10826
|
return { args: [], options: {}, callback: args };
|
|
@@ -10857,11 +10860,16 @@ function signalName(sig) {
|
|
|
10857
10860
|
if (typeof sig === "number") return SIGNAL_NAMES[sig] ?? String(sig);
|
|
10858
10861
|
return null;
|
|
10859
10862
|
}
|
|
10863
|
+
function decodeOutput(buf, encoding) {
|
|
10864
|
+
if (encoding === "buffer" || encoding === null) return buf;
|
|
10865
|
+
const enc = encoding === void 0 ? "utf8" : encoding;
|
|
10866
|
+
return buf.toString(enc);
|
|
10867
|
+
}
|
|
10860
10868
|
function spawnError(command, args, code, message) {
|
|
10861
10869
|
const err = new Error(message ?? `spawn ${command} ${code}`);
|
|
10862
10870
|
err.code = code;
|
|
10863
10871
|
err.errno = code === "ENOENT" ? -2 : void 0;
|
|
10864
|
-
err.syscall =
|
|
10872
|
+
err.syscall = `spawn ${command}`;
|
|
10865
10873
|
err.path = command;
|
|
10866
10874
|
err.spawnargs = args;
|
|
10867
10875
|
return err;
|
|
@@ -10883,16 +10891,22 @@ function createChildProcess({ ctx, process: process2, Buffer: Buffer2, handles,
|
|
|
10883
10891
|
this.#kernel = null;
|
|
10884
10892
|
this.#handle = null;
|
|
10885
10893
|
this.#closing = false;
|
|
10894
|
+
this.#exited = false;
|
|
10886
10895
|
}
|
|
10887
10896
|
#kernel;
|
|
10888
10897
|
#handle;
|
|
10889
10898
|
#closing;
|
|
10899
|
+
#exited;
|
|
10890
10900
|
kill(signal = "SIGTERM") {
|
|
10901
|
+
if (this.#exited || this.#closing || !this.#kernel) return false;
|
|
10891
10902
|
const name = signalName(signal) ?? "SIGTERM";
|
|
10892
10903
|
this.killed = true;
|
|
10893
|
-
if (!this.#kernel) return false;
|
|
10894
10904
|
try {
|
|
10895
10905
|
const ret = this.#kernel.kill(name);
|
|
10906
|
+
if (ret != null && typeof ret.then === "function") {
|
|
10907
|
+
ret.catch(() => {
|
|
10908
|
+
});
|
|
10909
|
+
}
|
|
10896
10910
|
return ret !== false;
|
|
10897
10911
|
} catch {
|
|
10898
10912
|
return false;
|
|
@@ -10923,6 +10937,7 @@ function createChildProcess({ ctx, process: process2, Buffer: Buffer2, handles,
|
|
|
10923
10937
|
/** @internal */
|
|
10924
10938
|
_markClosing() {
|
|
10925
10939
|
this.#closing = true;
|
|
10940
|
+
this.#exited = true;
|
|
10926
10941
|
}
|
|
10927
10942
|
get _closing() {
|
|
10928
10943
|
return this.#closing;
|
|
@@ -11009,20 +11024,46 @@ function createChildProcess({ ctx, process: process2, Buffer: Buffer2, handles,
|
|
|
11009
11024
|
if (child.stderr?._sliccPump) pumps.push(child.stderr._sliccPump(kernelChild.stderr));
|
|
11010
11025
|
child._stdioPumps = Promise.all(pumps);
|
|
11011
11026
|
}
|
|
11027
|
+
function safeEmit(child, event, ...args) {
|
|
11028
|
+
try {
|
|
11029
|
+
child.emit(event, ...args);
|
|
11030
|
+
} catch (err) {
|
|
11031
|
+
if (isExitError(err)) return err;
|
|
11032
|
+
throw err;
|
|
11033
|
+
}
|
|
11034
|
+
return null;
|
|
11035
|
+
}
|
|
11012
11036
|
function finish(child, code, signal) {
|
|
11013
11037
|
if (child._closing) return;
|
|
11014
11038
|
child._markClosing();
|
|
11015
11039
|
child.exitCode = code;
|
|
11016
11040
|
child.signalCode = signal;
|
|
11017
|
-
child
|
|
11041
|
+
const exitErr = safeEmit(child, "exit", code, signal);
|
|
11042
|
+
if (exitErr) {
|
|
11043
|
+
child._release();
|
|
11044
|
+
handles.notify?.();
|
|
11045
|
+
return;
|
|
11046
|
+
}
|
|
11018
11047
|
const after = child._stdioPumps ?? Promise.resolve();
|
|
11019
11048
|
trackPromise(handles, after);
|
|
11020
11049
|
after.finally(() => {
|
|
11021
|
-
child
|
|
11050
|
+
const closeErr = safeEmit(child, "close", code, signal);
|
|
11022
11051
|
child._release();
|
|
11023
11052
|
handles.notify?.();
|
|
11053
|
+
if (closeErr) return;
|
|
11024
11054
|
});
|
|
11025
11055
|
}
|
|
11056
|
+
function decodeWait(status) {
|
|
11057
|
+
const sigNum = status?.signal;
|
|
11058
|
+
if (sigNum != null && sigNum !== 0) {
|
|
11059
|
+
return { code: null, signal: SIGNAL_NAMES[sigNum] ?? String(sigNum) };
|
|
11060
|
+
}
|
|
11061
|
+
const code = typeof status?.status === "number" ? status.status : 0;
|
|
11062
|
+
if (code > 128 && code < 128 + 32 && SIGNAL_NAMES[code - 128]) {
|
|
11063
|
+
return { code: null, signal: SIGNAL_NAMES[code - 128] };
|
|
11064
|
+
}
|
|
11065
|
+
return { code, signal: null };
|
|
11066
|
+
}
|
|
11026
11067
|
function startSpawn(child, file, args, options, stdio) {
|
|
11027
11068
|
const cwd = options.cwd != null ? String(options.cwd) : process2.cwd();
|
|
11028
11069
|
const env = options.env ? { ...options.env } : { ...process2.env };
|
|
@@ -11042,22 +11083,18 @@ function createChildProcess({ ctx, process: process2, Buffer: Buffer2, handles,
|
|
|
11042
11083
|
(kernelChild) => {
|
|
11043
11084
|
child._bindKernel(kernelChild);
|
|
11044
11085
|
connectStdio(child, kernelChild);
|
|
11045
|
-
child
|
|
11086
|
+
const spawnErr = safeEmit(child, "spawn");
|
|
11087
|
+
if (spawnErr) return;
|
|
11046
11088
|
const waitP = kernelChild.wait();
|
|
11047
11089
|
trackPromise(handles, waitP);
|
|
11048
11090
|
waitP.then(
|
|
11049
11091
|
(status) => {
|
|
11050
|
-
const
|
|
11051
|
-
|
|
11052
|
-
const name = SIGNAL_NAMES[sigNum] ?? String(sigNum);
|
|
11053
|
-
finish(child, null, name);
|
|
11054
|
-
} else {
|
|
11055
|
-
const code = typeof status?.status === "number" ? status.status : 0;
|
|
11056
|
-
finish(child, code, null);
|
|
11057
|
-
}
|
|
11092
|
+
const { code, signal } = decodeWait(status);
|
|
11093
|
+
finish(child, code, signal);
|
|
11058
11094
|
},
|
|
11059
11095
|
(err) => {
|
|
11060
|
-
|
|
11096
|
+
if (isExitError(err)) return;
|
|
11097
|
+
safeEmit(child, "error", err);
|
|
11061
11098
|
finish(child, 1, null);
|
|
11062
11099
|
}
|
|
11063
11100
|
);
|
|
@@ -11074,15 +11111,23 @@ function createChildProcess({ ctx, process: process2, Buffer: Buffer2, handles,
|
|
|
11074
11111
|
} catch {
|
|
11075
11112
|
}
|
|
11076
11113
|
process2.nextTick(() => {
|
|
11077
|
-
child
|
|
11114
|
+
const emitErr = safeEmit(child, "error", error);
|
|
11115
|
+
if (emitErr) {
|
|
11116
|
+
child._release();
|
|
11117
|
+
handles.notify?.();
|
|
11118
|
+
return;
|
|
11119
|
+
}
|
|
11078
11120
|
if (code === "ENOENT") {
|
|
11079
11121
|
child.exitCode = -2;
|
|
11080
|
-
child.
|
|
11122
|
+
child._markClosing();
|
|
11123
|
+
setTimeout(() => {
|
|
11124
|
+
safeEmit(child, "close", -2, null);
|
|
11125
|
+
child._release();
|
|
11126
|
+
handles.notify?.();
|
|
11127
|
+
}, 20);
|
|
11081
11128
|
} else {
|
|
11082
11129
|
finish(child, 1, null);
|
|
11083
11130
|
}
|
|
11084
|
-
child._release();
|
|
11085
|
-
handles.notify?.();
|
|
11086
11131
|
});
|
|
11087
11132
|
}
|
|
11088
11133
|
);
|
|
@@ -11117,53 +11162,95 @@ function createChildProcess({ ctx, process: process2, Buffer: Buffer2, handles,
|
|
|
11117
11162
|
const child = spawn(String(file), norm.args, opts);
|
|
11118
11163
|
if (!norm.callback) return child;
|
|
11119
11164
|
const maxBuffer = opts.maxBuffer ?? 1024 * 1024;
|
|
11165
|
+
const encoding = opts.encoding;
|
|
11166
|
+
const killSignal = signalName(opts.killSignal) ?? "SIGTERM";
|
|
11120
11167
|
let stdout = Buffer2.alloc(0);
|
|
11121
11168
|
let stderr = Buffer2.alloc(0);
|
|
11122
11169
|
let exited = false;
|
|
11170
|
+
let timedOut = false;
|
|
11171
|
+
let timer;
|
|
11172
|
+
const clearTimer = () => {
|
|
11173
|
+
if (timer) {
|
|
11174
|
+
clearTimeout(timer);
|
|
11175
|
+
timer = void 0;
|
|
11176
|
+
}
|
|
11177
|
+
};
|
|
11123
11178
|
const done = (err) => {
|
|
11124
11179
|
if (exited) return;
|
|
11125
11180
|
exited = true;
|
|
11126
|
-
|
|
11127
|
-
const out =
|
|
11128
|
-
const errOut =
|
|
11181
|
+
clearTimer();
|
|
11182
|
+
const out = decodeOutput(stdout, encoding);
|
|
11183
|
+
const errOut = decodeOutput(stderr, encoding);
|
|
11184
|
+
if (err) {
|
|
11185
|
+
err.stdout = out;
|
|
11186
|
+
err.stderr = errOut;
|
|
11187
|
+
}
|
|
11129
11188
|
norm.callback(err, out, errOut);
|
|
11130
11189
|
};
|
|
11131
|
-
if (
|
|
11132
|
-
|
|
11133
|
-
|
|
11190
|
+
if (opts.timeout != null && opts.timeout > 0) {
|
|
11191
|
+
timer = setTimeout(() => {
|
|
11192
|
+
timedOut = true;
|
|
11193
|
+
child.kill(killSignal);
|
|
11194
|
+
}, Number(opts.timeout));
|
|
11195
|
+
timer.unref?.();
|
|
11196
|
+
}
|
|
11197
|
+
const append = (kind, chunk) => {
|
|
11198
|
+
const buf = Buffer2.isBuffer(chunk) ? chunk : Buffer2.from(chunk);
|
|
11199
|
+
if (kind === "stdout") {
|
|
11200
|
+
stdout = Buffer2.concat([stdout, buf]);
|
|
11134
11201
|
if (stdout.length > maxBuffer) {
|
|
11202
|
+
stdout = stdout.subarray(0, maxBuffer);
|
|
11135
11203
|
child.kill();
|
|
11136
|
-
const err = new Error("stdout maxBuffer exceeded");
|
|
11204
|
+
const err = new Error("stdout maxBuffer length exceeded");
|
|
11137
11205
|
err.code = "ERR_CHILD_PROCESS_STDIO_MAXBUFFER";
|
|
11138
11206
|
done(err);
|
|
11207
|
+
return false;
|
|
11139
11208
|
}
|
|
11140
|
-
}
|
|
11141
|
-
|
|
11142
|
-
if (child.stderr) {
|
|
11143
|
-
child.stderr.on("data", (chunk) => {
|
|
11144
|
-
stderr = Buffer2.concat([stderr, Buffer2.isBuffer(chunk) ? chunk : Buffer2.from(chunk)]);
|
|
11209
|
+
} else {
|
|
11210
|
+
stderr = Buffer2.concat([stderr, buf]);
|
|
11145
11211
|
if (stderr.length > maxBuffer) {
|
|
11212
|
+
stderr = stderr.subarray(0, maxBuffer);
|
|
11146
11213
|
child.kill();
|
|
11147
|
-
const err = new Error("stderr maxBuffer exceeded");
|
|
11214
|
+
const err = new Error("stderr maxBuffer length exceeded");
|
|
11148
11215
|
err.code = "ERR_CHILD_PROCESS_STDIO_MAXBUFFER";
|
|
11149
11216
|
done(err);
|
|
11217
|
+
return false;
|
|
11150
11218
|
}
|
|
11219
|
+
}
|
|
11220
|
+
return true;
|
|
11221
|
+
};
|
|
11222
|
+
if (child.stdout) {
|
|
11223
|
+
child.stdout.on("data", (chunk) => {
|
|
11224
|
+
append("stdout", chunk);
|
|
11225
|
+
});
|
|
11226
|
+
}
|
|
11227
|
+
if (child.stderr) {
|
|
11228
|
+
child.stderr.on("data", (chunk) => {
|
|
11229
|
+
append("stderr", chunk);
|
|
11151
11230
|
});
|
|
11152
11231
|
}
|
|
11153
11232
|
child.on("error", (err) => done(err));
|
|
11154
11233
|
child.on("close", (code, signal) => {
|
|
11155
11234
|
if (exited) return;
|
|
11235
|
+
const cmd = opts._execCmd != null ? String(opts._execCmd) : `${file} ${norm.args.join(" ")}`.trim();
|
|
11236
|
+
if (timedOut) {
|
|
11237
|
+
const err2 = new Error(`Command failed: ${cmd}`);
|
|
11238
|
+
err2.code = null;
|
|
11239
|
+
err2.killed = true;
|
|
11240
|
+
err2.signal = killSignal;
|
|
11241
|
+
err2.cmd = cmd;
|
|
11242
|
+
done(err2);
|
|
11243
|
+
return;
|
|
11244
|
+
}
|
|
11156
11245
|
if (code === 0 && !signal) {
|
|
11157
11246
|
done(null);
|
|
11158
11247
|
return;
|
|
11159
11248
|
}
|
|
11160
|
-
const err = new Error(`Command failed: ${
|
|
11249
|
+
const err = new Error(`Command failed: ${cmd}`);
|
|
11161
11250
|
err.code = code;
|
|
11162
11251
|
err.killed = child.killed;
|
|
11163
11252
|
err.signal = signal;
|
|
11164
|
-
err.cmd =
|
|
11165
|
-
err.stdout = opts.encoding ? stdout.toString(opts.encoding) : stdout;
|
|
11166
|
-
err.stderr = opts.encoding ? stderr.toString(opts.encoding) : stderr;
|
|
11253
|
+
err.cmd = cmd;
|
|
11167
11254
|
done(err);
|
|
11168
11255
|
});
|
|
11169
11256
|
return child;
|
|
@@ -11177,7 +11264,8 @@ function createChildProcess({ ctx, process: process2, Buffer: Buffer2, handles,
|
|
|
11177
11264
|
}
|
|
11178
11265
|
opts = opts && typeof opts === "object" ? opts : {};
|
|
11179
11266
|
const shell = typeof opts.shell === "string" ? opts.shell : "sh";
|
|
11180
|
-
|
|
11267
|
+
const cmd = String(command);
|
|
11268
|
+
return execFile(shell, ["-c", cmd], { ...opts, shell: false, _execCmd: cmd }, cb);
|
|
11181
11269
|
}
|
|
11182
11270
|
return {
|
|
11183
11271
|
spawn,
|
|
@@ -16019,6 +16107,8 @@ function createNextTick() {
|
|
|
16019
16107
|
|
|
16020
16108
|
// src/runtime/process.mjs
|
|
16021
16109
|
var NODE_SHIM_VERSION = "22.22.0";
|
|
16110
|
+
var SIGNAL_EXIT_CODES = { SIGTERM: 143, SIGINT: 130, SIGHUP: 129, SIGKILL: 137 };
|
|
16111
|
+
var SIGNAL_BY_NUMBER = { 1: "SIGHUP", 2: "SIGINT", 9: "SIGKILL", 15: "SIGTERM" };
|
|
16022
16112
|
function toBytes2(value) {
|
|
16023
16113
|
if (typeof value === "string") return value;
|
|
16024
16114
|
if (value instanceof Uint8Array) return value;
|
|
@@ -16210,6 +16300,69 @@ function createStdin(ctx, handles, Buffer2) {
|
|
|
16210
16300
|
}
|
|
16211
16301
|
};
|
|
16212
16302
|
}
|
|
16303
|
+
function readProcessCreds(ctx) {
|
|
16304
|
+
const fromProc = (text) => {
|
|
16305
|
+
let uid = 0;
|
|
16306
|
+
let euid = 0;
|
|
16307
|
+
let gid = 0;
|
|
16308
|
+
let egid = 0;
|
|
16309
|
+
let groups = [0];
|
|
16310
|
+
for (const line of text.split("\n")) {
|
|
16311
|
+
if (line.startsWith("Uid:")) {
|
|
16312
|
+
const parts = line.slice(4).trim().split(/\s+/).map(Number);
|
|
16313
|
+
uid = parts[0] ?? 0;
|
|
16314
|
+
euid = parts[1] ?? uid;
|
|
16315
|
+
} else if (line.startsWith("Gid:")) {
|
|
16316
|
+
const parts = line.slice(4).trim().split(/\s+/).map(Number);
|
|
16317
|
+
gid = parts[0] ?? 0;
|
|
16318
|
+
egid = parts[1] ?? gid;
|
|
16319
|
+
} else if (line.startsWith("Groups:")) {
|
|
16320
|
+
const parts = line.slice(7).trim().split(/\s+/).filter(Boolean).map(Number);
|
|
16321
|
+
if (parts.length) groups = parts;
|
|
16322
|
+
}
|
|
16323
|
+
}
|
|
16324
|
+
return { uid, euid, gid, egid, groups };
|
|
16325
|
+
};
|
|
16326
|
+
const tryRead = (path) => {
|
|
16327
|
+
try {
|
|
16328
|
+
const bytes = ctx.sync?.fs?.readFile?.(path);
|
|
16329
|
+
if (!bytes) return null;
|
|
16330
|
+
return typeof bytes === "string" ? bytes : new TextDecoder().decode(bytes);
|
|
16331
|
+
} catch {
|
|
16332
|
+
return null;
|
|
16333
|
+
}
|
|
16334
|
+
};
|
|
16335
|
+
for (const path of [`/proc/self/status`, `/proc/${ctx.pid}/status`]) {
|
|
16336
|
+
const text = tryRead(path);
|
|
16337
|
+
if (text) return fromProc(text);
|
|
16338
|
+
}
|
|
16339
|
+
const name = ctx.env?.USER || ctx.env?.LOGNAME || "root";
|
|
16340
|
+
const passwd = tryRead("/etc/passwd");
|
|
16341
|
+
if (passwd) {
|
|
16342
|
+
for (const line of passwd.split("\n")) {
|
|
16343
|
+
if (!line || line.startsWith("#")) continue;
|
|
16344
|
+
const [user, , uidStr, gidStr] = line.split(":");
|
|
16345
|
+
if (user !== name) continue;
|
|
16346
|
+
const uid = Number(uidStr) || 0;
|
|
16347
|
+
const gid = Number(gidStr) || 0;
|
|
16348
|
+
const groups = [gid];
|
|
16349
|
+
const group = tryRead("/etc/group");
|
|
16350
|
+
if (group) {
|
|
16351
|
+
for (const gline of group.split("\n")) {
|
|
16352
|
+
if (!gline || gline.startsWith("#")) continue;
|
|
16353
|
+
const [gname, , ggid, members] = gline.split(":");
|
|
16354
|
+
const g = Number(ggid);
|
|
16355
|
+
if (!Number.isFinite(g)) continue;
|
|
16356
|
+
if (gname === name || members && members.split(",").includes(name)) {
|
|
16357
|
+
if (!groups.includes(g)) groups.push(g);
|
|
16358
|
+
}
|
|
16359
|
+
}
|
|
16360
|
+
}
|
|
16361
|
+
return { uid, euid: uid, gid, egid: gid, groups };
|
|
16362
|
+
}
|
|
16363
|
+
}
|
|
16364
|
+
return { uid: 0, euid: 0, gid: 0, egid: 0, groups: [0] };
|
|
16365
|
+
}
|
|
16213
16366
|
var Process = class extends EventEmitter {
|
|
16214
16367
|
constructor({ ctx, argv, nextTick, onExit, handles, Buffer: Buffer2 }) {
|
|
16215
16368
|
super();
|
|
@@ -16325,39 +16478,55 @@ var Process = class extends EventEmitter {
|
|
|
16325
16478
|
cwd() {
|
|
16326
16479
|
return this._cwd;
|
|
16327
16480
|
}
|
|
16328
|
-
/**
|
|
16481
|
+
/** Real kernel credentials (from /proc or /etc/passwd for USER). */
|
|
16482
|
+
_creds() {
|
|
16483
|
+
if (this._credCache) return this._credCache;
|
|
16484
|
+
this._credCache = readProcessCreds(this._ctx);
|
|
16485
|
+
return this._credCache;
|
|
16486
|
+
}
|
|
16329
16487
|
getuid() {
|
|
16330
|
-
return
|
|
16488
|
+
return this._creds().uid;
|
|
16331
16489
|
}
|
|
16332
16490
|
geteuid() {
|
|
16333
|
-
return
|
|
16491
|
+
return this._creds().euid;
|
|
16334
16492
|
}
|
|
16335
16493
|
getgid() {
|
|
16336
|
-
return
|
|
16494
|
+
return this._creds().gid;
|
|
16337
16495
|
}
|
|
16338
16496
|
getegid() {
|
|
16339
|
-
return
|
|
16497
|
+
return this._creds().egid;
|
|
16340
16498
|
}
|
|
16341
16499
|
getgroups() {
|
|
16342
|
-
return
|
|
16500
|
+
return this._creds().groups.slice();
|
|
16343
16501
|
}
|
|
16344
16502
|
/**
|
|
16345
|
-
* Minimal process.kill:
|
|
16346
|
-
*
|
|
16503
|
+
* Minimal process.kill: this process, plus signal 0 as a liveness check.
|
|
16504
|
+
* Unknown / dead pids → ESRCH (Node).
|
|
16347
16505
|
*/
|
|
16348
16506
|
kill(pid, signal = "SIGTERM") {
|
|
16349
16507
|
const target = Number(pid);
|
|
16350
|
-
|
|
16508
|
+
const esrch = () => {
|
|
16351
16509
|
const err = new Error(`kill ESRCH`);
|
|
16352
16510
|
err.code = "ESRCH";
|
|
16353
16511
|
err.errno = -3;
|
|
16354
16512
|
err.syscall = "kill";
|
|
16355
16513
|
throw err;
|
|
16514
|
+
};
|
|
16515
|
+
if (signal === 0 || signal === "0") {
|
|
16516
|
+
if (target !== this.pid) esrch();
|
|
16517
|
+
return true;
|
|
16518
|
+
}
|
|
16519
|
+
if (target !== this.pid) esrch();
|
|
16520
|
+
let name;
|
|
16521
|
+
if (typeof signal === "string") {
|
|
16522
|
+
name = signal.startsWith("SIG") ? signal : `SIG${signal}`;
|
|
16523
|
+
} else if (typeof signal === "number") {
|
|
16524
|
+
name = SIGNAL_BY_NUMBER[signal] ?? "SIGTERM";
|
|
16525
|
+
} else {
|
|
16526
|
+
name = "SIGTERM";
|
|
16356
16527
|
}
|
|
16357
|
-
|
|
16358
|
-
|
|
16359
|
-
const codes = { SIGTERM: 143, SIGINT: 130, SIGHUP: 129, SIGKILL: 137 };
|
|
16360
|
-
this.exit(codes[name] ?? 1);
|
|
16528
|
+
if (SIGNAL_EXIT_CODES[name] != null) {
|
|
16529
|
+
this.exit(SIGNAL_EXIT_CODES[name]);
|
|
16361
16530
|
}
|
|
16362
16531
|
return true;
|
|
16363
16532
|
}
|