abla/sys/linux/process
Generated from source.
Import with import "abla/sys/linux/process".
Source: abla/sys/linux/process/entry.ab
ablaLinuxArgumentCount (extern)
noescape extern:"intrinsic" fun ablaLinuxArgumentCount(): int
Returns the number of command-line arguments excluding the executable.
ablaLinuxArgument (extern)
noescape extern:"intrinsic" fun ablaLinuxArgument(index: int): string
Returns a program argument by index, with -1 selecting the executable and an empty string for an invalid index.
ablaLinuxEnvironmentPointer (extern)
noescape extern:"intrinsic" fun ablaLinuxEnvironmentPointer(): i64*
Returns a borrowed pointer to the process's null-terminated environment vector.
LinuxEnvironmentValue (class)
class LinuxEnvironmentValue(val value: string, val found: bool)
Holds the value and a presence flag that distinguishes a missing variable from an empty value.
LinuxProcessResult (class)
class LinuxProcessResult(val status: int, val output: string, val timedOut: bool = false)
Holds the child process status and its captured output, if any.
LinuxCommand (class)
class LinuxCommand(
val arguments: array<string>,
val overrides: array<string> = [],
var workingDirectory: string = "",
var inputPath: string = "",
var outputPath: string = "",
var errorPath: string = "",
val removed: array<string> = []
)
Describes the arguments, environment changes, working directory, and stream redirections for one command.
LinuxChildProcess (class)
class LinuxChildProcess(val process: int)
Holds a child process identifier, with a negative value indicating launch failure.
linuxArgumentCount (fun)
fun linuxArgumentCount(): int
Returns the number of command-line arguments after the executable.
linuxArgument (fun)
fun linuxArgument(index: int): string
Argument index (0 the first after the program, -1 the program itself), or "" past the end: reading past argv used to fault.
linuxEnvironmentPointer (fun)
fun linuxEnvironmentPointer(): i64*
Returns a borrowed pointer to the process's null-terminated environment vector.
linuxEnvironment (fun)
trusted fun linuxEnvironment(name: string): LinuxEnvironmentValue
Looks up environment variable name exactly. Returns its text and found=true when present, including an empty value, or empty text and found=false otherwise.
linuxExecutablePath (fun)
trusted fun linuxExecutablePath(executable: string): string
Returns the first executable match in PATH's absolute directories, the original text for a path containing a slash, or "" for a name with no match. A bare name never resolves against the working directory: not through an empty PATH entry ("a::b", a leading or trailing ':'), nor "." or another relative entry, nor by handing the bare name to execve when PATH has no match (execve reads a name without a slash against the working directory). The compiler starts its tools by bare name (ld.lld, clang, llvm-config, codesign, ...) in the directory of the tree it builds, which may carry a file of that name; an empty result makes the exec fail (ENOENT) instead.
linuxWaitProcess (fun)
trusted fun linuxWaitProcess(process: int, noHang: bool = false): LinuxProcessResult
Collects process and returns its decoded wait status. With noHang true, returns status -1 and output pending when the child is still running. A wait error returns status -1 and empty output.
linuxStackLimits (fun)
trusted fun linuxStackLimits(): array<int>
The stack limits (RLIMIT_STACK) in bytes: [soft, hard], -1 for unlimited, or [] when they cannot be read.
linuxSetStackLimits (fun)
trusted fun linuxSetStackLimits(soft: int, hard: int): bool
Returns true if the host accepts the requested soft and hard stack limits in bytes.
linuxReexecute (fun)
trusted fun linuxReexecute(): void
Replaces this process with a fresh run of its own executable and the same arguments (only returns when that fails).
linuxReexecuteWithEnvironment (fun)
trusted fun linuxReexecuteWithEnvironment(environment: array<string>): void
linuxReexecute with environment (NAME=value entries) as the new run's whole environment (only returns when the exec fails).
linuxExecute (fun)
trusted fun linuxExecute(executable: string, arguments: array<string>): int
Replaces this process with executable, given arguments as its argv (the first is its argv[0]). The standard streams, the working directory and the environment carry over. Only returns, with 127, when the exec fails.
linuxCommand (fun)
fun linuxCommand(executable: string): LinuxCommand
Creates a command configuration with executable as its initial argument. It does not start a process.
LinuxCommand.argument (extension fun)
fun LinuxCommand.argument(value: string): LinuxCommand
Appends value as one argument and returns this command configuration.
LinuxCommand.environment (extension fun)
fun LinuxCommand.environment(name: string, value: string): LinuxCommand
name set to value for what this command starts, replacing what an earlier call set it to; the rest of the environment carries over.
LinuxCommand.removeEnvironment (extension fun)
fun LinuxCommand.removeEnvironment(name: string): LinuxCommand
name taken out of what the command inherits. A later environment of that name still sets it.
LinuxCommand.directory (extension fun)
fun LinuxCommand.directory(path: string): LinuxCommand
Where the command runs, instead of this process's working directory.
LinuxCommand.input (extension fun)
fun LinuxCommand.input(path: string): LinuxCommand
Standard input read from this file.
LinuxCommand.output (extension fun)
fun LinuxCommand.output(path: string): LinuxCommand
Standard output written to this file, created if missing (with the mode a file already there has) and emptied. "/dev/null" discards it.
LinuxCommand.errors (extension fun)
fun LinuxCommand.errors(path: string): LinuxCommand
Standard error written to this file, as with output.
linuxEnvironmentEntries (fun)
trusted fun linuxEnvironmentEntries(): array<string>
This process's environment, as NAME=value entries in their order.
linuxSignalWatchState (fun)
trusted fun linuxSignalWatchState(): int
Per-thread watched mask, original mask bits, then 64 reference counts. fork copies the calling thread's state for the child, so it can unblock only that thread's watched signals before exec.
linuxSignalWatchGet (fun)
trusted fun linuxSignalWatchGet(offset: int): int
Returns the native word at byte offset in the calling thread's signal-watch state, or 0 when offset is not one of its words.
linuxSignalWatchSet (fun)
trusted fun linuxSignalWatchSet(offset: int, value: int): void
Writes a native word at byte offset in the calling thread's signal-watch state; does nothing when offset is not one of its words.
linuxForkFailureAt (var)
var linuxForkFailureAt: int
A child unblocks signals through the thread-local watch state: create it before the fork, so the child does not allocate it. A test seam (the process-pipeline test cannot interpose libc fork any more): the nth fork after linuxFailForkNumber(n) fails as if the process limit were reached.
linuxForkCount (var)
var linuxForkCount: int
Counts fork attempts while simulated fork failure is enabled.
linuxFailForkNumber (fun)
fun linuxFailForkNumber(number: int): void
Resets the test counter and makes the selected fork fail, or disables simulated failure for a nonpositive number.
linuxChildSetProcessGroup (fun)
trusted fun linuxChildSetProcessGroup(group: int): int
setpgid(0, group) in a forked child (group 0: one of its own); its parent sets the group too, which closes the fork/exec race. On macOS the two calls can meet and the child's fail with EPERM (arm64 CI run 44865623174) when the group is already the one asked for: that is no failure. So is a session leader's EPERM, its group being its own. 0, or the negative errno. Allocation-free, as a forked child must be.
LinuxExecAddresses (class)
class LinuxExecAddresses(
val executable: int,
val directory: int,
val input: int,
val output: int,
val error: int
)
C-string addresses of what a child needs (0 = none), into native memory that execStrings copied them to before the fork, so a child only uses these numbers and allocates nothing. Not nativeCStringAddress: its copy is on the collected heap, held by nothing but the number, so a collection in any allocation before the exec (the argument and environment vectors) could take it, and the child exec'd freed bytes (#829).
LinuxCommand.run (extension fun)
trusted fun LinuxCommand.run(): int
Forks the configured command and waits for its status. Returns 127 on launch or child setup failure and -1 when waiting fails.
LinuxCommand.execute (extension fun)
fun LinuxCommand.execute(): int
Replaces this process with the command: nothing after it runs, unless it fails, when it returns 127.
LinuxCommand.capture (extension fun)
trusted fun LinuxCommand.capture(timeoutMilliseconds: int = 0, interruptDescriptor: int = -1): LinuxProcessResult
Runs the configured command and returns its status and captured stdout. Launch failure returns 127 and empty output. On Linux and macOS a positive timeoutMilliseconds bounds the capture and child wait. Expiry kills the process group and returns timedOut with empty output. For a bounded capture, a nonnegative interruptDescriptor reads signal records. An interrupt kills the group and returns 128 plus the signal.
LinuxCommand.captureText (extension fun)
fun LinuxCommand.captureText(): string
Runs the configured command and returns captured stdout. Use capture if you need its status.
LinuxCommand.start (extension fun)
trusted fun LinuxCommand.start(): LinuxChildProcess
Forks the configured command and returns a child handle. A failed fork gives a negative process ID. Setup or exec errors in the child exit with status 127.
linuxStartConfiguredProcess (fun)
trusted fun linuxStartConfiguredProcess(
directory: string,
arguments: array<string>,
environmentNames: array<string> = [],
environmentValues: array<string> = [],
outputPath: string = ""
): LinuxChildProcess
Starts a process in its own process group. Environment entries override the inherited environment through the system env utility, while directory and descriptor setup happen directly in the forked child. Keeping this in Abla makes hosted build tools independent of a project-specific C launcher.
LinuxChildProcess.poll (extension fun)
fun LinuxChildProcess.poll(): int
Checks the child without blocking. Returns its exit status if collected, or -1 while pending or on wait failure. A completed status is consumed.
LinuxChildProcess.stopTree (extension fun)
trusted fun LinuxChildProcess.stopTree(graceMilliseconds: int = 100): int
Signals the child's process group with TERM and waits up to graceMilliseconds before escalating to KILL for the group. Use with a child started in its own group. Returns the child's status or -1 on failure.
LinuxChildProcess.stop (extension fun)
trusted fun LinuxChildProcess.stop(graceMilliseconds: int = 5000): int
Signals the child with TERM and waits up to graceMilliseconds before escalating to KILL. Returns the collected status, or -1 for an invalid child or failed wait.
linuxSleepMillisecondsChecked (fun)
fun linuxSleepMillisecondsChecked(milliseconds: int): bool
Sleeps for milliseconds, resuming after interruption. Returns false for a negative duration, a duration too large to convert to nanoseconds, or a system error.
linuxSleep (fun)
fun linuxSleep(milliseconds: int): void
Sleeps for the requested milliseconds and discards the result of the checked sleep.
linuxSleepNanoseconds (fun)
fun linuxSleepNanoseconds(nanoseconds: int): bool
Sleeps for the requested nanoseconds, returning false for an invalid duration or a system error.
linuxMonotonicNanosecondsWithBuffer (fun)
trusted fun linuxMonotonicNanosecondsWithBuffer(
var timestamp: NativeByteBuffer
): int
Returns a monotonic timestamp in nanoseconds, or zero if the clock read fails or the scratch buffer is unusable.
LinuxMonotonicClock (class)
resource class LinuxMonotonicClock(
var timestamp: NativeByteBuffer,
var requested: NativeByteBuffer,
var remaining: NativeByteBuffer
)
Owns scratch buffers for repeated nanosecond clock reads and sleeps.
LinuxMonotonicClock.valid (method)
fun valid(): bool
Returns true while all three clock buffers are open and hold at least 16 bytes.
LinuxMonotonicClock.nanoseconds (method)
fun nanoseconds(): int
Returns a monotonic timestamp in nanoseconds, or zero if the clock read or its scratch buffer fails.
LinuxMonotonicClock.sleepNanoseconds (method)
fun sleepNanoseconds(nanoseconds: int): bool
Sleeps using the clock's scratch buffers and returns false for an invalid duration, unusable buffer, or system error.
LinuxMonotonicClock.drop (method)
fun drop(): void
Closes all scratch buffers owned by the clock.
linuxMonotonicClock (fun)
fun linuxMonotonicClock(): LinuxMonotonicClock
Returns a monotonic clock with reusable buffers for time reads and sleeps.
linuxMonotonicNanoseconds (fun)
fun linuxMonotonicNanoseconds(): int
Ambient providers used by the compiler stay on the same libc-free syscall layer as ordinary Abla programs. These helpers expose values, while compile capability policy remains the compiler evaluator's responsibility.
linuxMonotonicMilliseconds (fun)
fun linuxMonotonicMilliseconds(): int
Returns a monotonic timestamp in whole milliseconds, or zero if the clock read fails.
linuxRealtimeNanoseconds (fun)
fun linuxRealtimeNanoseconds(): int
Wall-clock time: nanoseconds since 1970-01-01T00:00:00Z.
linuxRandomInteger (fun)
trusted fun linuxRandomInteger(maxExclusive: int): int
Returns a random value below maxExclusive, or zero for a nonpositive bound or a failed random read.
LinuxPipelinePipe (class)
class LinuxPipelinePipe(val input: int, val output: int)
A close-on-exec pipe used for data, the start barrier and exec failure reports.
LinuxCommand.snapshot (extension fun)
fun LinuxCommand.snapshot(): LinuxCommand
A private copy prevents later mutations to a Command changing a pipeline.
LinuxPipelineResult (class)
class LinuxPipelineResult(
val statuses: array<int>,
val output: string,
val errors: string,
val launchError: string,
val status: int
)
Holds the ordered child statuses, captured streams, and any launch failure from a pipeline.
LinuxPipelineResult.allSucceeded (method)
fun allSucceeded(): bool
Returns true if the pipeline launched at least one child with no launch error and every child exited successfully.
LinuxRunningPipeline (class)
class LinuxRunningPipeline(
val processes: array<int>,
val group: int,
val outputDescriptor: int,
val errorDescriptor: int,
val launchError: string,
var result: LinuxPipelineResult? = null
)
Tracks the running children and capture descriptors until the pipeline result is collected.
linuxPipelineStart (fun)
trusted fun linuxPipelineStart(commands: array<LinuxCommand>, grouped: bool, capture: bool,
captureErrors: bool): LinuxRunningPipeline
The parent and each child close every unused pipe end. The barrier keeps the first child alive until all stages have joined its process group.
LinuxRunningPipeline.wait (extension fun)
fun LinuxRunningPipeline.wait(): LinuxPipelineResult
Drains captured streams and returns the child statuses and any launch error, reusing the result on later calls.
LinuxRunningPipeline.stop (extension fun)
trusted fun LinuxRunningPipeline.stop(graceMilliseconds: int = 5000): LinuxPipelineResult
Signals the process group when present, waits for completion, and returns the same result as wait.
Built from Abla v0.2.79 source ba5d6b7d. Examples and generated signatures follow that source revision.