Repository navigation
feat(process): make process.title settable (#1401) - #1509
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1401.
Summary
process.title = Xnow round-trips through a thread-local cell.process.titlereads still fall back to argv[0] when unset.prctl(PR_SET_NAME)so/proc/<pid>/commreflects the new value. macOS has no per-process equivalent — Node has the same best-effort behavior.Approach
Expr::ProcessTitleHIR variant (getter) andExpr::ProcessSetTitle(Box<Expr>)(setter).expr_member.rsroutesprocess.titlereads (bare + viaglobalThis.process) to the getter;expr_assign.rsdetectsprocess.title = Xon the LHS and lowers to the setter.js_process_titleand the setter tojs_process_set_title(value).type_analysistagsExpr::ProcessTitleasType::Stringso chained string methods take the fast path.PROCESS_TITLEthread-local cell stores the value; getter reads it; setter writes it (+prctl(PR_SET_NAME)on Linux).Test plan
test-parity/node-suite/process/title/title-set(pre-existing from node:process — argv0/execPath/title not exposed as string properties #1346) now passes.cargo fmt --all -- --checkclean.