Skip to content

feat(process): make process.title settable (#1401) - #1509

Merged
proggeramlug merged 1 commit into
mainfrom
worktree-fix-1401-title-set
May 23, 2026
Merged

proggeramlug merged 1 commit into
mainfrom
worktree-fix-1401-title-set

Conversation

@proggeramlug

Copy link
Copy Markdown
Contributor

Closes #1401.

Summary

  • process.title = X now round-trips through a thread-local cell.
  • process.title reads still fall back to argv[0] when unset.
  • On Linux, the setter also calls prctl(PR_SET_NAME) so /proc/<pid>/comm reflects the new value. macOS has no per-process equivalent — Node has the same best-effort behavior.

Approach

  • New Expr::ProcessTitle HIR variant (getter) and Expr::ProcessSetTitle(Box<Expr>) (setter).
  • expr_member.rs routes process.title reads (bare + via globalThis.process) to the getter; expr_assign.rs detects process.title = X on the LHS and lowers to the setter.
  • Codegen routes the getter to js_process_title and the setter to js_process_set_title(value).
  • type_analysis tags Expr::ProcessTitle as Type::String so chained string methods take the fast path.
  • PROCESS_TITLE thread-local cell stores the value; getter reads it; setter writes it (+ prctl(PR_SET_NAME) on Linux).

Test plan

After #1346 `process.title` returned argv[0] as a read-only string,
but the issue noted the setter path was missing — `process.title = X`
silently fell through to the GlobalGet sentinel, so subsequent reads
still returned argv[0] and the test for "settable" failed.

Wire it up:

- New `Expr::ProcessTitle` HIR variant (getter) and
  `Expr::ProcessSetTitle(Box<Expr>)` (setter). expr_member.rs routes
  `process.title` reads (bare + via globalThis) to the getter;
  expr_assign.rs detects the `process.title = X` shape on the LHS
  and lowers to the setter.
- Codegen: getter calls `js_process_title`, setter calls
  `js_process_set_title(value)`. type_analysis tags
  `Expr::ProcessTitle` as `Type::String` so chained `.startsWith` /
  template-literal use takes the fast path.
- Runtime: thread-local `PROCESS_TITLE` cell stores the assigned value;
  the getter returns it (falling back to argv[0] when unset). On Linux
  the setter also calls `prctl(PR_SET_NAME)` so `/proc/<pid>/comm`
  updates. macOS has no per-process equivalent — Node has the same
  best-effort behavior; the assignment is still observable via reads.
- Parity case `node-suite/process/title/title-set` (pre-existing,
  from #1346 bring-up) now passes.
@proggeramlug
proggeramlug merged commit 9b814b4 into main May 23, 2026
9 checks passed
@proggeramlug
proggeramlug deleted the worktree-fix-1401-title-set branch May 23, 2026 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

node:process — process.title should be settable

1 participant