diff --git a/backend/src/api.ts b/backend/src/api.ts index 90537f3..8efe921 100644 --- a/backend/src/api.ts +++ b/backend/src/api.ts @@ -436,9 +436,10 @@ export class Session { this.log(`Tearing down session`); this.tearingDown = true; allSessions.delete(this); - await new Promise((resolve) => setTimeout(resolve, 5000)); - await this.run(this.privilegedTeardown()); - await this.returnUID(); + if (this.uidInfo) { + await this.run(this.privilegedTeardown()); + await this.returnUID(); + } this.ws.terminate(); } catch (err) { this.log(`Error during teardown`); diff --git a/backend/src/test-runner.ts b/backend/src/test-runner.ts index 7c29111..972dbc7 100644 --- a/backend/src/test-runner.ts +++ b/backend/src/test-runner.ts @@ -37,6 +37,7 @@ class Test { run = async () => { let session = null; + let timeout = null; try { const that = this; this.ws = { @@ -70,7 +71,7 @@ class Test { session = new api.Session(this.ws, this.lang, (msg: string) => { this.messages.push({ event: "serverLog", message: msg }); }); - setTimeout(() => { + timeout = setTimeout(() => { this.timedOut = true; this.handleUpdate(); }, TIMEOUT_MS); @@ -98,6 +99,9 @@ class Test { } } finally { this.ws = null; + if (timeout) { + clearTimeout(timeout); + } if (session) { await session.teardown(); } @@ -228,7 +232,7 @@ const testTypes: { repl: { pred: ({ repl }) => (repl ? true : false), }, - runRepl: { + runrepl: { pred: ({ repl }) => (repl ? true : false), }, scope: { @@ -266,7 +270,6 @@ async function main() { try { await test.run(); console.error("succeeded"); - console.error(test.getLog()); } catch (err) { console.error("failed:"); console.error(test.getLog()); diff --git a/system/src/riju-system-privileged.c b/system/src/riju-system-privileged.c index e9a774a..b6dfd6a 100644 --- a/system/src/riju-system-privileged.c +++ b/system/src/riju-system-privileged.c @@ -26,7 +26,7 @@ void die_with_usage() " riju-system-privileged useradd UID\n" " riju-system-privileged setup UID UUID\n" " riju-system-privileged spawn UID UUID CMDLINE...\n" - " riju-system-privileged teardown UUID"); + " riju-system-privileged teardown UID UUID"); } int parseUID(char *str) @@ -125,7 +125,7 @@ void teardown(int uid, char *uuid) users = buf; } if (users != NULL) { - if (asprintf(&cmdline, "pkill -SIGKILL --uid %s", users) < 0) + if (asprintf(&cmdline, "while pkill -9 --uid %1$s; do sleep 0.01; done", users) < 0) die("asprintf failed"); status = system(cmdline); if (status != 0 && status != 256)