bigass changes

- ls beginnings,
- added groups to shellstate
- made buffers optional in result factory functions,
- made an enum signal map,
- fixed a minor bug in path resolver that didnt output the '/' if     the inode was at root (inode 0) from the moment it was called

- added code that attaches the shell to the built-in IDE terminal

--

tests need fixing, new code needs testing
This commit is contained in:
2026-08-24 10:30:04 +02:00
parent 48aac3c883
commit dad18cd4cc
14 changed files with 380 additions and 82 deletions
+43 -27
View File
@@ -2,7 +2,7 @@ import type { CommandDescriptor } from "@core/command";
import type { CommandIO } from "@core/command_io";
import { createErrorResult, createSuccessResult, type ResultError, type ResultSuccess } from "@core/result";
import type { ShellState } from "@core/shell_state";
import type { Signal } from "@core/signal";
import { SIGNAL_MAP, type Signal } from "@core/signal";
import type { ShellError, SignalTerminationError } from "@core/util/errors";
import { createImmutableBuffer } from "@core/util/immutable_buffer";
import { EventEmitter } from "./event_emitter";
@@ -128,9 +128,9 @@ export class Process {
"GenericError",
"Promised output from command function rejected",
{},
createImmutableBuffer(new Uint8Array()),
createImmutableBuffer(new Uint8Array()),
this.CommandDescriptor.name,
undefined,
undefined,
{
name: "Caught error",
message: String(error),
@@ -144,32 +144,48 @@ export class Process {
public sendSignal(signal: Signal): void {
if (this._Settled) return;
//Make global signals an enum later on
if (signal.type === "SIGKILL") {
if (this._SignalHandler !== null) {
this._SignalHandler(signal);
this._SignalHandler = null;
}
const result: ResultError<SignalTerminationError> = createErrorResult(
"SignalTermination",
`Process ${this.PID} killed by a ${signal.type}`,
{ signalNumber: signal.type, signalName: SIGNAL_MAP[signal.type] },
this.CommandDescriptor.name,
);
this._Settled = true;
const result: ResultError<SignalTerminationError> = createErrorResult(
"SignalTermination",
`Process ${this.PID} killed by signal sigkill`,
{ signalNumber: 9, signalName: signal.type },
createImmutableBuffer(new Uint8Array()),
createImmutableBuffer(new Uint8Array()),
this.CommandDescriptor.name,
);
this._EventEmitter.emit("result", { pid: this.PID, result, state: this.State });
return;
} else {
if (this._SignalHandler !== null) {
this._SignalHandler(signal);
switch (signal.type) {
case SIGNAL_MAP.SIGKILL:
this._SignalHandler = null;
} else {
this._SignalQueue.push(signal);
}
this._Settled = true;
this._EventEmitter.emit("result", { pid: this.PID, result: result, state: this.State });
return;
case SIGNAL_MAP.SIGTERM:
if (this._SignalHandler !== null) {
this._SignalHandler(signal);
this._SignalHandler = null;
}
this._Settled = true;
this._EventEmitter.emit("result", { pid: this.PID, result: result, state: this.State });
return;
case SIGNAL_MAP.SIGINT:
if (this._SignalHandler !== null) {
this._SignalHandler(signal);
this._SignalHandler = null;
}
this._Settled = true;
this._EventEmitter.emit("result", { pid: this.PID, result: result, state: this.State });
return;
default:
if (this._SignalHandler !== null) {
this._SignalHandler(signal);
this._SignalHandler = null;
} else {
this._SignalQueue.push(signal);
}
}
}