@waffle-os/runtime 0.0.150 → 0.0.151
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/browser/process-broker.ts +42 -4
- package/dist/browser/process-broker.js +47 -2
- package/dist/interrupt/rewriter-internal.js +2 -1
- package/dist/proc/abi.js +20 -6
- package/dist/proc/directory.js +111 -0
- package/dist/proc/errors.js +1 -0
- package/dist/proc/supervisor.js +130 -24
- package/dist/proc/table.js +9 -1
- package/dist/proc/types.js +5 -0
- package/dist/proc/worker-client.js +34 -5
- package/dist/runtime.js +3 -0
- package/dist/tooling/program/program-transformer.json +1 -1
- package/interrupt/rewriter-internal.ts +2 -1
- package/package.json +1 -1
- package/proc/abi.ts +25 -4
- package/proc/directory.ts +131 -0
- package/proc/errors.ts +1 -0
- package/proc/supervisor.ts +173 -36
- package/proc/table.ts +11 -0
- package/proc/types.ts +6 -0
- package/proc/worker-client.ts +36 -5
- package/runtime.ts +3 -0
- package/tooling/program/program-transformer.json +1 -1
package/proc/worker-client.ts
CHANGED
|
@@ -40,6 +40,8 @@ import {
|
|
|
40
40
|
directorySlots,
|
|
41
41
|
directoryJob,
|
|
42
42
|
findDirectoryJob,
|
|
43
|
+
probeDirectoryJob,
|
|
44
|
+
probeDirectoryLogicalPid,
|
|
43
45
|
directoryControls,
|
|
44
46
|
isCollectedProcess,
|
|
45
47
|
reserveDirectoryProcess,
|
|
@@ -72,6 +74,7 @@ import {
|
|
|
72
74
|
ProcessErrno,
|
|
73
75
|
ProcessError,
|
|
74
76
|
checkedSignal,
|
|
77
|
+
checkedKillSignal,
|
|
75
78
|
checkedJobLifetime,
|
|
76
79
|
type JobLifetime,
|
|
77
80
|
checkedProcessCwd,
|
|
@@ -476,6 +479,10 @@ export class WorkerProcessClient {
|
|
|
476
479
|
if (commandTransferFailed(this.options.transport.commandTransfer))
|
|
477
480
|
throw new ProcessError(ProcessErrno.SRCH, "command transfer cleanup failed");
|
|
478
481
|
}
|
|
482
|
+
private checkAlive(): void {
|
|
483
|
+
if (readOutcome(this.signals.outcome))
|
|
484
|
+
throw new ProcessError(ProcessErrno.SRCH, "process has exited");
|
|
485
|
+
}
|
|
479
486
|
private admit(): void {
|
|
480
487
|
if (readOutcome(this.signals.outcome)) {
|
|
481
488
|
this.retireAccesses();
|
|
@@ -909,6 +916,7 @@ export class WorkerProcessClient {
|
|
|
909
916
|
}
|
|
910
917
|
canSignal(callerPid: number, pid: number): boolean {
|
|
911
918
|
if (callerPid !== this.pid) return false;
|
|
919
|
+
this.checkAlive();
|
|
912
920
|
const target = this.find(pid);
|
|
913
921
|
return directoryControls(
|
|
914
922
|
this.options.transport.directory,
|
|
@@ -931,18 +939,41 @@ export class WorkerProcessClient {
|
|
|
931
939
|
true,
|
|
932
940
|
);
|
|
933
941
|
} catch (error) {
|
|
934
|
-
if (error instanceof ProcessError && error.errno ===
|
|
942
|
+
if (error instanceof ProcessError && error.errno === ProcessErrno.PERM) return false;
|
|
935
943
|
throw error;
|
|
936
944
|
}
|
|
937
945
|
}
|
|
946
|
+
canProbeJob(callerPid: number, job: number): boolean {
|
|
947
|
+
if (callerPid !== this.pid) return false;
|
|
948
|
+
this.checkAlive();
|
|
949
|
+
return probeDirectoryJob(this.options.transport.directory, this.pid, job);
|
|
950
|
+
}
|
|
951
|
+
canSignalProcess(callerPid: number, processId: number): boolean {
|
|
952
|
+
if (callerPid !== this.pid) return false;
|
|
953
|
+
this.checkAlive();
|
|
954
|
+
return probeDirectoryLogicalPid(
|
|
955
|
+
this.options.transport.directory,
|
|
956
|
+
callerPid,
|
|
957
|
+
processId,
|
|
958
|
+
this.options.transport.slot,
|
|
959
|
+
);
|
|
960
|
+
}
|
|
938
961
|
kill(pid: number, signal: number): void {
|
|
962
|
+
const sig = checkedKillSignal(signal);
|
|
939
963
|
if (!this.canSignal(this.pid, pid))
|
|
940
|
-
throw new ProcessError(
|
|
941
|
-
|
|
964
|
+
throw new ProcessError(ProcessErrno.PERM, "process is outside the caller's ancestry");
|
|
965
|
+
if (sig === 0) return;
|
|
966
|
+
this.deliver([this.find(pid)], sig);
|
|
942
967
|
}
|
|
943
968
|
killJob(job: number, signal: number): void {
|
|
969
|
+
const sig = checkedKillSignal(signal);
|
|
970
|
+
if (sig === 0) {
|
|
971
|
+
if (!this.canProbeJob(this.pid, job))
|
|
972
|
+
throw new ProcessError(ProcessErrno.PERM, "job is not owned by the caller");
|
|
973
|
+
return;
|
|
974
|
+
}
|
|
944
975
|
if (!this.canSignalJob(this.pid, job))
|
|
945
|
-
throw new ProcessError(
|
|
976
|
+
throw new ProcessError(ProcessErrno.PERM, "job is not owned by the caller");
|
|
946
977
|
const directory = this.options.transport.directory;
|
|
947
978
|
const slots = directorySlots(directory);
|
|
948
979
|
const targets: ReturnType<typeof directoryState>[] = [];
|
|
@@ -957,7 +988,7 @@ export class WorkerProcessClient {
|
|
|
957
988
|
if (!isCollectedProcess(error)) throw error;
|
|
958
989
|
}
|
|
959
990
|
}
|
|
960
|
-
this.deliver(targets,
|
|
991
|
+
this.deliver(targets, sig, true);
|
|
961
992
|
}
|
|
962
993
|
private deliver(
|
|
963
994
|
targets: { slot: number; pid: number; parentPid: number; signals: SignalTransport }[],
|
package/runtime.ts
CHANGED
|
@@ -313,7 +313,10 @@ const supervisorCapabilities = {
|
|
|
313
313
|
jobOf: "method",
|
|
314
314
|
cwd: "method",
|
|
315
315
|
canSignal: "method",
|
|
316
|
+
canProbe: "method",
|
|
316
317
|
canSignalJob: "method",
|
|
318
|
+
canProbeJob: "method",
|
|
319
|
+
canSignalProcess: "method",
|
|
317
320
|
canWaitJob: "method",
|
|
318
321
|
accessStart: "method",
|
|
319
322
|
accessTake: "method",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"commit":"
|
|
1
|
+
{"commit":"da522cacff05cf6f18e820967a2e0f52d2f19680","buildToolsSha256":"b617652c1601f8722bb85c3a688a1fca4985b53f2c2066c10c76c2e693081137","optimizerSourceSha256":"34c4a040f3cf639f039823880822c6541c384c9b4eaa116d27dda8d9cb5c9f9e"}
|