feat(os): add CurrentProcess identity, executable, working directory and uptime #262
Loading…
Reference in a new issue
No description provided.
Delete branch "loop/251-current-process"
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?
Refs #251
Part 1 of 2. This adds
CurrentProcesstostd/oswithidentifier(),parentIdentifier(),executable(),workingDirectory()anduptime(), besideProcess.executablePath().Part 2 waits for the seed. The compiler calls
Process.executablePath(), so moving its callers toCurrentProcess.executable()and removing the old native (the rest of #251) can only land once a seed withCurrentProcessis published. That's why this PR says Refs, not Closes.Windows.processIdentity(GetCurrentProcessId, Toolhelp snapshot for the parent),Posix.processIdentity(getpid/getppid), and the OS-neutralCurrentProcess.executablePath/workingDirectoryPath/uptimeNanosecondsinruntime/process.c.torb_natives.handmachine_natives.care regenerated: 248 → 253 rows.torb_machine_current_process_executableanswers the entry file, the same wayProcess.executablePathdoes.torb_file_absolute_path("."), so it always matchesFile.absolutePath("."), sandbox included.torb_os_freebsd_executable_pathreadssysctl KERN_PROC_PATHNAME, so the platform executable path now answers there too. It is compiled on FreeBSD only and has not run there yet.Durationcan only be built from seconds or milliseconds.std/os/tests/process.test.trb, plus the conformance casecurrent-process, which runs under both the VM and native.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
torbto rundocs skill.docs declarationsanddocs skill --checkin 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
CurrentProcessbefore part 2 (migrate callers, removeProcess.executablePath).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 #2514a3afacf3b8d4490aef98d4490aef9c092ae2647Checklist for
c092ae2:std/os/tests/process.test.trb(identifiers vs. a child's$PPID/CIM, executable exists, working directory equalsFile.absolutePath("."), uptime grows and is bounded by machine uptime) plus conformance casecurrent-process` (VM and native). CI green on this head (tier A/B, bootstrap, same-C, gates, pdisc).OsError.Missing); POSIXparent <= 0is mapped to Missing; the VM substitute answers the entry file and falls back to the native outsidetorb run; uptime rounds up to whole ms; FreeBSD sysctl sizing/NUL handling is sound.Process.executablePathcorrectly wait for a seed withCurrentProcess. No seed impact for this PR.os.md,process.md, OS.md, VM.md, runtime README and the skills mirrors updated; pdisc green.runtimeOf/systemRuntimeOfrows;torb_natives.h/machine_natives.cregenerated.Non-blocking:
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.CurrentProcessidentity, executable and working directory (OS slice 2, part 2) #251CurrentProcessresources, processors and memory limit (OS slice 2, part 3) #252