@code-yeongyu/senpi-pty 2026.11.19-3 → 2026.11.19-4

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.
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Linux `oom_score_adj` for every child a terminal session starts: the maximum, so under memory pressure the
3
+ * kernel's OOM killer picks a runaway tool process (and its descendants, which inherit the value) before the
4
+ * long-lived host that spawned it. Unprivileged processes may raise their own children's value.
5
+ */
6
+ export declare const TOOL_CHILD_OOM_SCORE_ADJ = 1000;
7
+ /**
8
+ * Marks `pid` as the preferred OOM victim on Linux; a no-op elsewhere or without a pid. Never throws. Best effort:
9
+ * the write lands just after the spawn, so a process the child forked before it keeps the inherited value.
10
+ */
11
+ export declare function preferAsOomVictim(pid: number | undefined): void;
12
+ //# sourceMappingURL=oom-score.d.ts.map
@@ -0,0 +1,24 @@
1
+ import { writeFileSync } from "node:fs";
2
+ import process from "node:process";
3
+ /**
4
+ * Linux `oom_score_adj` for every child a terminal session starts: the maximum, so under memory pressure the
5
+ * kernel's OOM killer picks a runaway tool process (and its descendants, which inherit the value) before the
6
+ * long-lived host that spawned it. Unprivileged processes may raise their own children's value.
7
+ */
8
+ export const TOOL_CHILD_OOM_SCORE_ADJ = 1000;
9
+ /**
10
+ * Marks `pid` as the preferred OOM victim on Linux; a no-op elsewhere or without a pid. Never throws. Best effort:
11
+ * the write lands just after the spawn, so a process the child forked before it keeps the inherited value.
12
+ */
13
+ export function preferAsOomVictim(pid) {
14
+ if (process.platform !== "linux" || pid === undefined)
15
+ return;
16
+ try {
17
+ writeFileSync(`/proc/${pid}/oom_score_adj`, String(TOOL_CHILD_OOM_SCORE_ADJ));
18
+ }
19
+ catch {
20
+ // Best effort: a child that already exited (ENOENT/ESRCH) or a locked-down /proc (EACCES) keeps its
21
+ // inherited value; the spawn itself must not fail over it.
22
+ }
23
+ }
24
+ //# sourceMappingURL=oom-score.js.map
package/dist/session.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Buffer } from "node:buffer";
2
2
  import process from "node:process";
3
3
  import { loadNativePty } from "./native-loader.js";
4
+ import { preferAsOomVictim } from "./oom-score.js";
4
5
  import { PipeFallbackSession, shouldUsePipeFallback } from "./pipe-fallback.js";
5
6
  import { stopLeftoverGroup } from "./process-tree.js";
6
7
  import { createBunTerminalSession, isBunTerminalEnabled } from "./session-bun.js";
@@ -110,6 +111,7 @@ export class TerminalSession {
110
111
  if (backendHandle === null || backendValue === null) {
111
112
  throw new Error("Terminal session backend did not initialize");
112
113
  }
114
+ preferAsOomVictim(this.pid);
113
115
  if (backendValue === "native" && backendHandle.onData) {
114
116
  this.unsubscribeBackendData = backendHandle.onData((chunk) => this.emitData(chunk));
115
117
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-yeongyu/senpi-pty",
3
- "version": "2026.11.19-3",
3
+ "version": "2026.11.19-4",
4
4
  "description": "Typed PTY session loader for Senpi persistent terminals",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",