os: CurrentProcess identity, executable and working directory (OS slice 2, part 2) #251
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Goal
The first half of
CurrentProcess(OS.md section 5.9): the facts about this process that are cheap to read, and the move ofProcess.executablePath()toCurrentProcess.executable(), which also makes macOS and FreeBSD answer. Split from #126 (OS slice 2) to keep each PR to one or two commits.Source
Current state on main
std/oshasEnvironment,System,Directories,Entropy,OsErrorand the per-system halves; there is noCurrentProcess.Process.executablePath(): String?is a native ofstd/process(manifest rowProcess.executablePathincompiler/src/backend/c/natives.trb, C inruntime/process.coverruntime/platform.c;_NSGetExecutablePathis inruntime/os/macos.c). Callers:compiler/src/project/toolchain.trb,compiler/src/cli/run.trb,compiler/src/cli/host.trb,tools/registry/tests/*.test.trb, the VM (compiler/src/vm/interpret.trb).Scope
CurrentProcessinstd/os/src/process.trb, exported fromstd/os:identifier(),parentIdentifier(),executable(): Result<Path, OsError>,workingDirectory(): Result<Path, OsError>(through the sameplatform.cfunctionFile.absolutePathuses),uptime()(the runtime notes the monotonic clock beforemain).Process.executablePath()is removed once its callers are migrated.resources,processorsandmemoryLimitare the follow-up issue.Acceptance criteria
CurrentProcess.identifier()equals the process id the system reports;parentIdentifier()is a positive id on Linux, macOS and Windows (test compares against a spawned child's report of its parent).CurrentProcess.executable()is an absolutePathto an existing file on linux-x64, linux-arm64, macos-arm64 and windows-x64 (Linux/proc/self/exe, macOS_NSGetExecutablePathplusrealpath, WindowsGetModuleFileNameW, FreeBSDKERN_PROC_PATHNAMEper OS.md; the FreeBSD C is compiled only on FreeBSD).torb run),executable()answers whatProcess.executablePath()answers there today (the entry file); a test runs under both the VM and--native.workingDirectory()agrees withFile.absolutePath(".").uptime()is positive and not larger than the monotonic clock.Process.executablePathis gone fromstd/process, the manifest,runtime/process.cand the docs; every caller usesCurrentProcess.executable();torbstill finds itsstd/andruntime/on a macOS build.torb check --every-target std/osis clean (a gate oftools/gates.sh a);docs/standard-library/os.mdandprocess.mdare updated andskills/regenerated.TORB_RUNNERS) and otherwise on the portable workflow of the mirror. Every target is lowered bycheck --every-targeton linux-x64.Seed
Two commits, because the compiler itself calls the moved native. (1) Add
CurrentProcessand its natives besideProcess.executablePath(manifest rows for the new names; both forms work), then the seed is refreshed by the owner or the merge gate and theseedworkflow publishes it. (2) Migrate the callers and removeProcess.executablePath.Size
One PR, two Conventional Commits (
feat(os): ...thenrefactor(os): ...).Dependencies
OS slice 1 (done). Blocks #252 for
resources,processors,memoryLimitofCurrentProcessonly in that both editstd/os/src/process.trb.CurrentProcessresources, processors and memory limit (OS slice 2, part 3) #252ByteSize, memory and the current process (OS slice 2) #126ByteSize, memory and the current process (OS slice 2) #126ByteSize, memory and the current process (OS slice 2) #126[loop:torbscript] intake: in scope (author orion, label loop, split from #126), not a duplicate, no collision with a design record (OS.md 5.9). Body already carries goal, sources, criteria; #126 has landed. refine: ready as written, label set. Seed impact: see the body (the move of Process.executablePath follows the two-commit rule if a native goes).
[loop:torbscript] claim implement by session:loop-torbscript-20261009 until 2026-10-09T14:55Z
CurrentProcessresources, processors and memory limit (OS slice 2, part 3) #252[loop:torbscript] implement: part 1 landed with PR #262 (approved and merged by argus, merge commit
9ea9bb27): CurrentProcess identifier, parentIdentifier, executable, workingDirectory, uptime. Part 2 (migrate the compiler's callers of Process.executablePath to CurrentProcess.executable() and remove the old native) follows the two-commit rule and needs a published seed that contains CurrentProcess. Claim released. next: waiting (seed with CurrentProcess, published by the owner) until 2026-10-10T04:00:00ZCurrentProcessresources, processors and memory limit (OS slice 2, part 3) #252const r: RingList<Int> = [1, 2]) #212CurrentProcessresources, processors and memory limit (OS slice 2, part 3) #252[loop:torbscript] claim implement by session:loop-torbscript-20261010 until 2026-10-10T15:40Z (unblocked: the published seed torb-seed-5f22f071d02f of nightly-20261010 postdates the part 1 commit)
[loop:torbscript] implement: part 2 in PR #304 (one commit
refactor(os): ..., head11be6846): every caller of Process.executablePath (toolchain search, torb run key, script host key, debug adapter, registry tests, one conformance program) now calls CurrentProcess.executable(); Process.executablePath is removed from std/process, the manifest, runtime/process.c, torb.h and the VM substitute; torb_natives.h and machine_natives.c regenerated by hand (one thunk out, renumbered, count 258; the compiler tests compare them withtorb natives --header); conformance process-executable-path folded into current-process; docs (process.md, os.md, torb-run.md, OS.md, VM.md, RELEASE.md fact 5, runtime/README.md) and the skill references updated. No local build (CI only); CI: commit messages and pdisc green, bootstrap and gates queued on the runners. Argus requested as reviewer. Est. token usage ~150k. Claim released. next: waiting (review by argus)