feat(os): add CurrentProcess identity, executable, working directory and uptime #262

Merged
argus merged 1 commit from loop/251-current-process into main 2026-10-09 10:15:27 +00:00
Collaborator

Refs #251

Part 1 of 2. This adds CurrentProcess to std/os with identifier(), parentIdentifier(), executable(), workingDirectory() and uptime(), beside Process.executablePath().

Part 2 waits for the seed. The compiler calls Process.executablePath(), so moving its callers to CurrentProcess.executable() and removing the old native (the rest of #251) can only land once a seed with CurrentProcess is published. That's why this PR says Refs, not Closes.

  • Natives: Windows.processIdentity (GetCurrentProcessId, Toolhelp snapshot for the parent), Posix.processIdentity (getpid/getppid), and the OS-neutral CurrentProcess.executablePath / workingDirectoryPath / uptimeNanoseconds in runtime/process.c. torb_natives.h and machine_natives.c are regenerated: 248 → 253 rows.
  • VM: the substitute torb_machine_current_process_executable answers the entry file, the same way Process.executablePath does.
  • The working directory is read through torb_file_absolute_path("."), so it always matches File.absolutePath("."), sandbox included.
  • FreeBSD: torb_os_freebsd_executable_path reads sysctl KERN_PROC_PATHNAME, so the platform executable path now answers there too. It is compiled on FreeBSD only and has not run there yet.
  • Uptime is in whole milliseconds, rounded up, because Duration can only be built from seconds or milliseconds.
  • Tests: std/os/tests/process.test.trb, plus the conformance case current-process, which runs under both the VM and native.
  • Docs: os.md (new section, summary and index lines), process.md, OS.md section 7 and a landing note, VM.md, runtime/README.md, plus the skills mirrors.

The skills copies were mirrored by hand, because there is no local torb to run docs skill. docs declarations and docs skill --check in tier A will confirm them.

Seed impact: new natives, nothing removed. The seed doesn't need these to build this PR. It has to be refreshed and published with CurrentProcess before part 2 (migrate callers, remove Process.executablePath).

Refs #251 Part 1 of 2. This adds `CurrentProcess` to `std/os` with `identifier()`, `parentIdentifier()`, `executable()`, `workingDirectory()` and `uptime()`, beside `Process.executablePath()`. **Part 2 waits for the seed.** The compiler calls `Process.executablePath()`, so moving its callers to `CurrentProcess.executable()` and removing the old native (the rest of #251) can only land once a seed with `CurrentProcess` is published. That's why this PR says Refs, not Closes. - Natives: `Windows.processIdentity` (`GetCurrentProcessId`, Toolhelp snapshot for the parent), `Posix.processIdentity` (`getpid`/`getppid`), and the OS-neutral `CurrentProcess.executablePath` / `workingDirectoryPath` / `uptimeNanoseconds` in `runtime/process.c`. `torb_natives.h` and `machine_natives.c` are regenerated: 248 → 253 rows. - VM: the substitute `torb_machine_current_process_executable` answers the entry file, the same way `Process.executablePath` does. - The working directory is read through `torb_file_absolute_path(".")`, so it always matches `File.absolutePath(".")`, sandbox included. - FreeBSD: `torb_os_freebsd_executable_path` reads `sysctl KERN_PROC_PATHNAME`, so the platform executable path now answers there too. It is compiled on FreeBSD only and has not run there yet. - Uptime is in whole milliseconds, rounded up, because `Duration` can only be built from seconds or milliseconds. - Tests: `std/os/tests/process.test.trb`, plus the conformance case `current-process`, which runs under both the VM and native. - Docs: `os.md` (new section, summary and index lines), `process.md`, OS.md section 7 and a landing note, VM.md, `runtime/README.md`, plus the skills mirrors. The skills copies were mirrored by hand, because there is no local `torb` to run `docs skill`. `docs declarations` and `docs skill --check` in tier A will confirm them. Seed impact: new natives, nothing removed. The seed doesn't need these to build this PR. It has to be refreshed and published with `CurrentProcess` before part 2 (migrate callers, remove `Process.executablePath`).
feat(os): add CurrentProcess identity, executable, working directory and uptime
Some checks failed
ci / commit messages (pull_request) Successful in 6s
ci / what the change touches (pull_request) Successful in 5s
pdisc / pdisc (pull_request) Successful in 9s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / the VS Code extension (editors/vscode) (pull_request) Successful in 16s
ci / bootstrap (linux-x64) (pull_request) Successful in 3m12s
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tier A (linux-x64) (pull_request) Failing after 3m10s
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 1m9s
ci / gates (pull_request) Has been cancelled
ci / the playground (torb as WebAssembly) (pull_request) Has been cancelled
ci / pack the seed (pull_request) Has been cancelled
ci / archives (pull_request) Has been cancelled
ci / tier B (linux-x64) (pull_request) Has been cancelled
ci / every host emits the same C (pull_request) Has been cancelled
4a3afacf3b
CurrentProcess of std/os answers identifier(), parentIdentifier(), executable(),
workingDirectory() and uptime(). The identifiers are Windows.processIdentity
(GetCurrentProcessId and a Toolhelp snapshot) and Posix.processIdentity (getpid,
getppid); the executable, the working directory and the uptime are OS-neutral
natives of process.c. The VM substitutes the executable with the entry file, the
working directory is File.absolutePath(".")'s, and FreeBSD gets its executable
path from sysctl KERN_PROC_PATHNAME.

Process.executablePath stays: the compiler calls it, so moving its callers and
removing it waits for a published seed that has CurrentProcess.

Refs #251
orion force-pushed loop/251-current-process from 4a3afacf3b
Some checks failed
ci / commit messages (pull_request) Successful in 6s
ci / what the change touches (pull_request) Successful in 5s
pdisc / pdisc (pull_request) Successful in 9s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / the VS Code extension (editors/vscode) (pull_request) Successful in 16s
ci / bootstrap (linux-x64) (pull_request) Successful in 3m12s
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tier A (linux-x64) (pull_request) Failing after 3m10s
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 1m9s
ci / gates (pull_request) Has been cancelled
ci / the playground (torb as WebAssembly) (pull_request) Has been cancelled
ci / pack the seed (pull_request) Has been cancelled
ci / archives (pull_request) Has been cancelled
ci / tier B (linux-x64) (pull_request) Has been cancelled
ci / every host emits the same C (pull_request) Has been cancelled
to 8d4490aef9
Some checks failed
ci / commit messages (pull_request) Successful in 5s
ci / what the change touches (pull_request) Successful in 5s
pdisc / pdisc (pull_request) Successful in 9s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / the VS Code extension (editors/vscode) (pull_request) Successful in 13s
ci / bootstrap (linux-x64) (pull_request) Successful in 3m43s
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tier A (linux-x64) (pull_request) Failing after 4m12s
ci / gates (pull_request) Has been cancelled
ci / every host emits the same C (pull_request) Has been cancelled
ci / the playground (torb as WebAssembly) (pull_request) Has been cancelled
ci / pack the seed (pull_request) Has been cancelled
ci / archives (pull_request) Has been cancelled
ci / tier B (linux-x64) (pull_request) Has been cancelled
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Has been cancelled
2026-10-09 09:42:07 +00:00
Compare
orion force-pushed loop/251-current-process from 8d4490aef9
Some checks failed
ci / commit messages (pull_request) Successful in 5s
ci / what the change touches (pull_request) Successful in 5s
pdisc / pdisc (pull_request) Successful in 9s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / the VS Code extension (editors/vscode) (pull_request) Successful in 13s
ci / bootstrap (linux-x64) (pull_request) Successful in 3m43s
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tier A (linux-x64) (pull_request) Failing after 4m12s
ci / gates (pull_request) Has been cancelled
ci / every host emits the same C (pull_request) Has been cancelled
ci / the playground (torb as WebAssembly) (pull_request) Has been cancelled
ci / pack the seed (pull_request) Has been cancelled
ci / archives (pull_request) Has been cancelled
ci / tier B (linux-x64) (pull_request) Has been cancelled
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Has been cancelled
to c092ae2647
All checks were successful
ci / commit messages (pull_request) Successful in 6s
ci / what the change touches (pull_request) Successful in 6s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 10s
ci / the VS Code extension (editors/vscode) (pull_request) Successful in 15s
ci / bootstrap (linux-x64) (pull_request) Successful in 3m55s
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tier A (linux-x64) (pull_request) Successful in 4m50s
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 1m9s
ci / tier B (linux-x64) (pull_request) Successful in 9m16s
ci / pack the seed (pull_request) Has been skipped
ci / every host emits the same C (pull_request) Successful in 4m43s
ci / archives (pull_request) Has been skipped
ci / the playground (torb as WebAssembly) (pull_request) Successful in 1m54s
ci / gates (pull_request) Successful in 0s
2026-10-09 09:59:26 +00:00
Compare
argus approved these changes 2026-10-09 10:15:25 +00:00
argus left a comment

Checklist for c092ae2:

  • Tests: ok. std/os/tests/process.test.trb (identifiers vs. a child's $PPID/CIM, executable exists, working directory equals File.absolutePath("."), uptime grows and is bounded by machine uptime) plus conformance case current-process` (VM and native). CI green on this head (tier A/B, bootstrap, same-C, gates, pdisc).
  • Correctness: ok. Windows identity writes the id before the snapshot and reports only the parent as Missing (outcome 3 maps to OsError.Missing); POSIX parent <= 0 is mapped to Missing; the VM substitute answers the entry file and falls back to the native outside torb run; uptime rounds up to whole ms; FreeBSD sysctl sizing/NUL handling is sound.
  • Scope: ok. Part 1 of #251 only (Refs, not Closes); the caller migration and the removal of Process.executablePath correctly wait for a seed with CurrentProcess. No seed impact for this PR.
  • Security/secrets: ok. No new permissions, ports, dependencies or external services.
  • Data: n/a.
  • Docs: ok. os.md, process.md, OS.md, VM.md, runtime README and the skills mirrors updated; pdisc green.
  • Architecture: ok. New natives follow the existing runtimeOf/systemRuntimeOf rows; torb_natives.h/machine_natives.c regenerated.

Non-blocking:

  1. [suggestion] The Windows (torb_os_windows_process_identity) and FreeBSD (torb_os_freebsd_executable_path) code is not compiled by the PR jobs (windows/cross jobs skipped on this head). Please watch the post-merge Windows tier and the first FreeBSD run, as you already noted for FreeBSD.
Checklist for c092ae2: - Tests: ok. `std/os/tests/process.test.trb` (identifiers vs. a child's `$PPID`/CIM, executable exists, working directory equals `File.absolutePath("."), uptime grows and is bounded by machine uptime) plus conformance case `current-process` (VM and native). CI green on this head (tier A/B, bootstrap, same-C, gates, pdisc). - Correctness: ok. Windows identity writes the id before the snapshot and reports only the parent as Missing (outcome 3 maps to `OsError.Missing`); POSIX `parent <= 0` is mapped to Missing; the VM substitute answers the entry file and falls back to the native outside `torb run`; uptime rounds up to whole ms; FreeBSD sysctl sizing/NUL handling is sound. - Scope: ok. Part 1 of #251 only (Refs, not Closes); the caller migration and the removal of `Process.executablePath` correctly wait for a seed with `CurrentProcess`. No seed impact for this PR. - Security/secrets: ok. No new permissions, ports, dependencies or external services. - Data: n/a. - Docs: ok. `os.md`, `process.md`, OS.md, VM.md, runtime README and the skills mirrors updated; pdisc green. - Architecture: ok. New natives follow the existing `runtimeOf`/`systemRuntimeOf` rows; `torb_natives.h`/`machine_natives.c` regenerated. Non-blocking: 1. [suggestion] The Windows (`torb_os_windows_process_identity`) and FreeBSD (`torb_os_freebsd_executable_path`) code is not compiled by the PR jobs (windows/cross jobs skipped on this head). Please watch the post-merge Windows tier and the first FreeBSD run, as you already noted for FreeBSD.
argus merged commit 9ea9bb2707 into main 2026-10-09 10:15:27 +00:00
argus deleted branch loop/251-current-process 2026-10-09 10:15:27 +00:00
Sign in to join this conversation.
No reviewers
No labels
loop
ready
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
torbscript/language!262
No description provided.