Module
Module documentation.
moduleos.posix
Classes
Classes and inheritance.
classos.posix::SocketPair
@brief`SocketPair` type.
@details`SocketPair` encapsulates state and operations exported by the system module. It commonly stores runtime handles, protocol state, buffers, configuration, or collection data. Its methods define the primary behavior for the type. If the type owns external resources, prefer `dispose` or `close` for deterministic release.
class SocketPair {
/*
@brief `left_fd` field.classos.posix::Mapping
@brief`Mapping` type.
@details`Mapping` encapsulates state and operations exported by the system module. It commonly stores runtime handles, protocol state, buffers, configuration, or collection data. Its methods define the primary behavior for the type. If the type owns external resources, prefer `dispose` or `close` for deterministic release.
class Mapping {
/*
@brief `handle` field.Functions
Free functions and class methods.
functionos.posix::__posix_fd_pair_left
Signature
extern func __posix_fd_pair_left(handle: Int) -> Int;extern func __posix_fd_pair_left(handle: Int) -> Int;
/*
@brief Binds the low-level runtime symbol `__posix_fd_pair_right`.@briefBinds the low-level runtime symbol `__posix_fd_pair_left`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@param
- handleUnderlying runtime handle.
@returnReturns the operation result as `Int`.
functionos.posix::__posix_fd_pair_right
Signature
extern func __posix_fd_pair_right(handle: Int) -> Int;extern func __posix_fd_pair_right(handle: Int) -> Int;
/*
@brief Binds the low-level runtime symbol `__posix_fd_pair_free`.@briefBinds the low-level runtime symbol `__posix_fd_pair_right`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@param
- handleUnderlying runtime handle.
@returnReturns the operation result as `Int`.
functionos.posix::__posix_fd_pair_free
Signature
extern func __posix_fd_pair_free(handle: Int) -> Void;extern func __posix_fd_pair_free(handle: Int) -> Void;
/*
@brief Binds the low-level runtime symbol `__posix_read_fd`.@briefBinds the low-level runtime symbol `__posix_fd_pair_free`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@param
- handleUnderlying runtime handle.
@returnVoid
functionos.posix::__posix_read_fd
Signature
extern func __posix_read_fd(fd: Int, max_bytes: Int) -> String;extern func __posix_read_fd(fd: Int, max_bytes: Int) -> String;
/*
@brief Binds the low-level runtime symbol `__posix_write_fd`.@briefBinds the low-level runtime symbol `__posix_read_fd`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@param
- fdOperating-system file descriptor or socket descriptor.
- max_bytesMaximum number of bytes to read or process in this operation.
@returnReturns the operation result as `String`.
functionos.posix::__posix_write_fd
Signature
extern func __posix_write_fd(fd: Int, data: String) -> Int;extern func __posix_write_fd(fd: Int, data: String) -> Int;
/*
@brief Binds the low-level runtime symbol `__posix_close_fd`.@briefBinds the low-level runtime symbol `__posix_write_fd`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@param
- fdOperating-system file descriptor or socket descriptor.
- dataInput or output data buffer.
@returnReturns the operation result as `Int`.
functionos.posix::__posix_close_fd
Signature
extern func __posix_close_fd(fd: Int) -> Int;extern func __posix_close_fd(fd: Int) -> Int;
/*
@brief Binds the low-level runtime symbol `__posix_socketpair`.@briefBinds the low-level runtime symbol `__posix_close_fd`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@param
- fdOperating-system file descriptor or socket descriptor.
@returnReturns the operation result as `Int`.
functionos.posix::__posix_socketpair
Signature
extern func __posix_socketpair() -> Int;extern func __posix_socketpair() -> Int;
/*
@brief Binds the low-level runtime symbol `__posix_mkfifo`.@briefBinds the low-level runtime symbol `__posix_socketpair`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@returnReturns the operation result as `Int`.
functionos.posix::__posix_mkfifo
Signature
extern func __posix_mkfifo(path: String, mode: Int) -> Int;extern func __posix_mkfifo(path: String, mode: Int) -> Int;
/*
@brief Binds the low-level runtime symbol `__posix_unlink`.@briefBinds the low-level runtime symbol `__posix_mkfifo`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@param
- pathFile or directory path.
- modeMode value that selects permissions, behavior, or formatting rules for the operation.
@returnReturns the operation result as `Int`.
functionos.posix::__posix_unlink
Signature
extern func __posix_unlink(path: String) -> Int;extern func __posix_unlink(path: String) -> Int;
/*
@brief Binds the low-level runtime symbol `__posix_mmap_file`.@briefBinds the low-level runtime symbol `__posix_unlink`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@param
- pathFile or directory path.
@returnReturns the operation result as `Int`.
functionos.posix::__posix_mmap_file
Signature
extern func __posix_mmap_file(path: String, len: Int, writable: Int) -> Int;extern func __posix_mmap_file(path: String, len: Int, writable: Int) -> Int;
/*
@brief Binds the low-level runtime symbol `__posix_mmap_len`.@briefBinds the low-level runtime symbol `__posix_mmap_file`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@param
- pathFile or directory path.
- lenLength in bytes, characters, or elements to read, write, copy, or allocate.
- writableWhether the resource should be opened or treated as writable.
@returnReturns the operation result as `Int`.
functionos.posix::__posix_mmap_len
Signature
extern func __posix_mmap_len(handle: Int) -> Int;extern func __posix_mmap_len(handle: Int) -> Int;
/*
@brief Binds the low-level runtime symbol `__posix_mmap_read`.@briefBinds the low-level runtime symbol `__posix_mmap_len`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@param
- handleUnderlying runtime handle.
@returnReturns the operation result as `Int`.
functionos.posix::__posix_mmap_read
Signature
extern func __posix_mmap_read(handle: Int, offset: Int, max_bytes: Int) -> String;extern func __posix_mmap_read(handle: Int, offset: Int, max_bytes: Int) -> String;
/*
@brief Binds the low-level runtime symbol `__posix_mmap_write`.@briefBinds the low-level runtime symbol `__posix_mmap_read`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@param
- handleUnderlying runtime handle.
- offsetByte offset measured from the start position.
- max_bytesMaximum number of bytes to read or process in this operation.
@returnReturns the operation result as `String`.
functionos.posix::__posix_mmap_write
Signature
extern func __posix_mmap_write(handle: Int, offset: Int, data: String) -> Int;extern func __posix_mmap_write(handle: Int, offset: Int, data: String) -> Int;
/*
@brief Binds the low-level runtime symbol `__posix_mmap_sync`.@briefBinds the low-level runtime symbol `__posix_mmap_write`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@param
- handleUnderlying runtime handle.
- offsetByte offset measured from the start position.
- dataInput or output data buffer.
@returnReturns the operation result as `Int`.
functionos.posix::__posix_mmap_sync
Signature
extern func __posix_mmap_sync(handle: Int) -> Int;extern func __posix_mmap_sync(handle: Int) -> Int;
/*
@brief Binds the low-level runtime symbol `__posix_mmap_close`.@briefBinds the low-level runtime symbol `__posix_mmap_sync`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@param
- handleUnderlying runtime handle.
@returnReturns the operation result as `Int`.
functionos.posix::__posix_mmap_close
Signature
extern func __posix_mmap_close(handle: Int) -> Int;extern func __posix_mmap_close(handle: Int) -> Int;
/*@briefBinds the low-level runtime symbol `__posix_mmap_close`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@param
- handleUnderlying runtime handle.
@returnReturns the operation result as `Int`.
functionos.posix::SocketPair.init
Signature
func init(self: os.posix.SocketPair, left_fd: Int = -1, right_fd: Int = -1) -> Void func init(self: os.posix.SocketPair, left_fd: Int = -1, right_fd: Int = -1) -> Void {
self.left_fd = left_fd;
self.right_fd = right_fd;@briefInitializes a `SocketPair` instance.
@detailsEstablishes the initial field state for `SocketPair` so other methods can be called safely. Constructor logic should keep fields consistent and avoid leaking partially initialized resources.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
- left_fdLeft-side file descriptor used by pipe or socketpair operations.
- right_fdRight-side file descriptor used by pipe or socketpair operations.
@returnVoid
functionos.posix::SocketPair.close_left
Signature
func close_left(self: os.posix.SocketPair) -> ErrCode func close_left(self: os.posix.SocketPair) -> ErrCode {
if self.closed_left {
return std.OK;@briefCloses resources with `SocketPair.close_left`.
@detailsExecutes the `close_left` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnReturns `ErrCode`; on success the error code is `std.OK` or `OK`, and on failure the error code describes the failure while any returned value contains the usable partial result when available.
functionos.posix::SocketPair.close_right
Signature
func close_right(self: os.posix.SocketPair) -> ErrCode func close_right(self: os.posix.SocketPair) -> ErrCode {
if self.closed_right {
return std.OK;@briefCloses resources with `SocketPair.close_right`.
@detailsExecutes the `close_right` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnReturns `ErrCode`; on success the error code is `std.OK` or `OK`, and on failure the error code describes the failure while any returned value contains the usable partial result when available.
functionos.posix::SocketPair.close
Signature
func close(self: os.posix.SocketPair) -> ErrCode func close(self: os.posix.SocketPair) -> ErrCode {
let left_err: ErrCode = self.close_left();
let right_err: ErrCode = self.close_right();@briefCloses resources and makes later operations unavailable with `SocketPair.close`.
@detailsExecutes the `close` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnReturns `ErrCode`; on success the error code is `std.OK` or `OK`, and on failure the error code describes the failure while any returned value contains the usable partial result when available.
functionos.posix::SocketPair.read_left
Signature
func read_left(self: os.posix.SocketPair, max_bytes: Int) -> String, ErrCode func read_left(self: os.posix.SocketPair, max_bytes: Int) -> String, ErrCode {
if self.closed_left || self.left_fd < 0 || max_bytes < 0 {
return "", std.ERR_INVALID;@briefReads data with `SocketPair.read_left`.
@detailsExecutes the `read_left` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
- max_bytesMaximum number of bytes to read or process in this operation.
@returnReturns `String, ErrCode`; on success the error code is `std.OK` or `OK`, and on failure the error code describes the failure while any returned value contains the usable partial result when available.
functionos.posix::SocketPair.read_right
Signature
func read_right(self: os.posix.SocketPair, max_bytes: Int) -> String, ErrCode func read_right(self: os.posix.SocketPair, max_bytes: Int) -> String, ErrCode {
if self.closed_right || self.right_fd < 0 || max_bytes < 0 {
return "", std.ERR_INVALID;@briefReads data with `SocketPair.read_right`.
@detailsExecutes the `read_right` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
- max_bytesMaximum number of bytes to read or process in this operation.
@returnReturns `String, ErrCode`; on success the error code is `std.OK` or `OK`, and on failure the error code describes the failure while any returned value contains the usable partial result when available.
functionos.posix::SocketPair.write_left
Signature
func write_left(self: os.posix.SocketPair, data: String) -> Int, ErrCode func write_left(self: os.posix.SocketPair, data: String) -> Int, ErrCode {
if self.closed_left || self.left_fd < 0 {
return 0, std.ERR_INVALID;@briefWrites data with `SocketPair.write_left`.
@detailsExecutes the `write_left` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
- dataInput or output data buffer.
@returnReturns `Int, ErrCode`; on success the error code is `std.OK` or `OK`, and on failure the error code describes the failure while any returned value contains the usable partial result when available.
functionos.posix::SocketPair.write_right
Signature
func write_right(self: os.posix.SocketPair, data: String) -> Int, ErrCode func write_right(self: os.posix.SocketPair, data: String) -> Int, ErrCode {
if self.closed_right || self.right_fd < 0 {
return 0, std.ERR_INVALID;@briefWrites data with `SocketPair.write_right`.
@detailsExecutes the `write_right` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
- dataInput or output data buffer.
@returnReturns `Int, ErrCode`; on success the error code is `std.OK` or `OK`, and on failure the error code describes the failure while any returned value contains the usable partial result when available.
functionos.posix::SocketPair.dispose
Signature
func dispose(self: os.posix.SocketPair) -> Void func dispose(self: os.posix.SocketPair) -> Void {
_ = self.close();
}@briefExplicitly releases resources owned by `SocketPair`.
@detailsThis method deterministically cleans up file descriptors, network connections, native handles, buffers, or other external resources. Implementations should be idempotent where possible, and repeated calls must not corrupt object state.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnVoid
functionos.posix::SocketPair.deinit
Signature
func deinit(self: os.posix.SocketPair) -> Void func deinit(self: os.posix.SocketPair) -> Void {
_ = self.close();
}@briefReleases fallback resources at the end of the `SocketPair` lifetime.
@detailsThis destructor hook is called by object lifetime management to clean up underlying resources that were not released explicitly. Normal application code should prefer `dispose`, `close`, or the module-specific close function to release resources at a deterministic time.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnVoid
functionos.posix::Mapping.init
Signature
func init(self: os.posix.Mapping, handle: Int = 0, writable: Bool = false) -> Void func init(self: os.posix.Mapping, handle: Int = 0, writable: Bool = false) -> Void {
self.handle = handle;
self.writable = writable;@briefInitializes a `Mapping` instance.
@detailsEstablishes the initial field state for `Mapping` so other methods can be called safely. Constructor logic should keep fields consistent and avoid leaking partially initialized resources.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
- handleUnderlying runtime handle.
- writableWhether the resource should be opened or treated as writable.
@returnVoid
functionos.posix::Mapping.len
Signature
func len(self: os.posix.Mapping) -> Int func len(self: os.posix.Mapping) -> Int {
if self.closed || self.handle == 0 {
return 0;@briefReturns the element count or byte length with `Mapping.len`.
@detailsExecutes the `len` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnReturns the operation result as `Int`.
functionos.posix::Mapping.read
Signature
func read(self: os.posix.Mapping, offset: Int, max_bytes: Int) -> String, ErrCode func read(self: os.posix.Mapping, offset: Int, max_bytes: Int) -> String, ErrCode {
if self.closed || self.handle == 0 || offset < 0 || max_bytes < 0 {
return "", std.ERR_INVALID;@briefReads data with `Mapping.read`.
@detailsExecutes the `read` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
- offsetByte offset measured from the start position.
- max_bytesMaximum number of bytes to read or process in this operation.
@returnReturns `String, ErrCode`; on success the error code is `std.OK` or `OK`, and on failure the error code describes the failure while any returned value contains the usable partial result when available.
functionos.posix::Mapping.write
Signature
func write(self: os.posix.Mapping, offset: Int, data: String) -> Int, ErrCode func write(self: os.posix.Mapping, offset: Int, data: String) -> Int, ErrCode {
if self.closed || self.handle == 0 || !self.writable || offset < 0 {
return 0, std.ERR_INVALID;@briefWrites data with `Mapping.write`.
@detailsExecutes the `write` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
- offsetByte offset measured from the start position.
- dataInput or output data buffer.
@returnReturns `Int, ErrCode`; on success the error code is `std.OK` or `OK`, and on failure the error code describes the failure while any returned value contains the usable partial result when available.
functionos.posix::Mapping.sync
Signature
func sync(self: os.posix.Mapping) -> ErrCode func sync(self: os.posix.Mapping) -> ErrCode {
if self.closed || self.handle == 0 {
return std.ERR_INVALID;@briefProvides the system library operation `Mapping.sync`.
@detailsExecutes the `sync` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnReturns `ErrCode`; on success the error code is `std.OK` or `OK`, and on failure the error code describes the failure while any returned value contains the usable partial result when available.
functionos.posix::Mapping.close
Signature
func close(self: os.posix.Mapping) -> ErrCode func close(self: os.posix.Mapping) -> ErrCode {
if self.closed {
return std.OK;@briefCloses resources and makes later operations unavailable with `Mapping.close`.
@detailsExecutes the `close` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnReturns `ErrCode`; on success the error code is `std.OK` or `OK`, and on failure the error code describes the failure while any returned value contains the usable partial result when available.
functionos.posix::Mapping.dispose
Signature
func dispose(self: os.posix.Mapping) -> Void func dispose(self: os.posix.Mapping) -> Void {
_ = self.close();
}@briefExplicitly releases resources owned by `Mapping`.
@detailsThis method deterministically cleans up file descriptors, network connections, native handles, buffers, or other external resources. Implementations should be idempotent where possible, and repeated calls must not corrupt object state.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnVoid
functionos.posix::Mapping.deinit
Signature
func deinit(self: os.posix.Mapping) -> Void func deinit(self: os.posix.Mapping) -> Void {
_ = self.close();
}@briefReleases fallback resources at the end of the `Mapping` lifetime.
@detailsThis destructor hook is called by object lifetime management to clean up underlying resources that were not released explicitly. Normal application code should prefer `dispose`, `close`, or the module-specific close function to release resources at a deterministic time.
@param
- selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnVoid
functionos.posix::read_fd
Signature
func read_fd(fd: Int, max_bytes: Int) -> String, ErrCodefunc read_fd(fd: Int, max_bytes: Int) -> String, ErrCode {
if fd < 0 || max_bytes < 0 {
return "", std.ERR_INVALID;@briefReads data with `read_fd`.
@detailsExecutes the `read_fd` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- fdOperating-system file descriptor or socket descriptor.
- max_bytesMaximum number of bytes to read or process in this operation.
@returnReturns `String, ErrCode`; on success the error code is `std.OK` or `OK`, and on failure the error code describes the failure while any returned value contains the usable partial result when available.
functionos.posix::write_fd
Signature
func write_fd(fd: Int, data: String) -> Int, ErrCodefunc write_fd(fd: Int, data: String) -> Int, ErrCode {
if fd < 0 {
return 0, std.ERR_INVALID;@briefWrites data with `write_fd`.
@detailsExecutes the `write_fd` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- fdOperating-system file descriptor or socket descriptor.
- dataInput or output data buffer.
@returnReturns `Int, ErrCode`; on success the error code is `std.OK` or `OK`, and on failure the error code describes the failure while any returned value contains the usable partial result when available.
functionos.posix::close_fd
Signature
func close_fd(fd: Int) -> ErrCodefunc close_fd(fd: Int) -> ErrCode {
if fd < 0 {
return std.ERR_INVALID;@briefCloses resources with `close_fd`.
@detailsExecutes the `close_fd` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- fdOperating-system file descriptor or socket descriptor.
@returnReturns `ErrCode`; on success the error code is `std.OK` or `OK`, and on failure the error code describes the failure while any returned value contains the usable partial result when available.
functionos.posix::socketpair
Signature
func socketpair() -> os.posix.SocketPair, ErrCodefunc socketpair() -> os.posix.SocketPair, ErrCode {
let pair: Int = __posix_socketpair();
if pair == 0 {@briefProvides the system library operation `socketpair`.
@detailsExecutes the `socketpair` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@returnReturns `os.posix.SocketPair, ErrCode`; on success the error code is `std.OK` or `OK`, and on failure the error code describes the failure while any returned value contains the usable partial result when available.
functionos.posix::mkfifo
Signature
func mkfifo(path: String, mode: Int = 420) -> ErrCodefunc mkfifo(path: String, mode: Int = 420) -> ErrCode {
let rc: Int = __posix_mkfifo(path, mode);
if rc == 0 {@briefProvides the system library operation `mkfifo`.
@detailsExecutes the `mkfifo` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- pathFile or directory path.
- modeMode value that selects permissions, behavior, or formatting rules for the operation.
@returnReturns `ErrCode`; on success the error code is `std.OK` or `OK`, and on failure the error code describes the failure while any returned value contains the usable partial result when available.
functionos.posix::unlink
Signature
func unlink(path: String) -> ErrCodefunc unlink(path: String) -> ErrCode {
let rc: Int = __posix_unlink(path);
if rc == 0 {@briefProvides the system library operation `unlink`.
@detailsExecutes the `unlink` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- pathFile or directory path.
@returnReturns `ErrCode`; on success the error code is `std.OK` or `OK`, and on failure the error code describes the failure while any returned value contains the usable partial result when available.
functionos.posix::mmap_file
Signature
func mmap_file(path: String, len: Int, writable: Bool = false) -> os.posix.Mapping, ErrCodefunc mmap_file(path: String, len: Int, writable: Bool = false) -> os.posix.Mapping, ErrCode {
if len <= 0 {
return new os.posix.Mapping(), std.ERR_INVALID;@briefProvides the system library operation `mmap_file`.
@detailsExecutes the `mmap_file` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- pathFile or directory path.
- lenLength in bytes, characters, or elements to read, write, copy, or allocate.
- writableWhether the resource should be opened or treated as writable.
@returnReturns `os.posix.Mapping, ErrCode`; on success the error code is `std.OK` or `OK`, and on failure the error code describes the failure while any returned value contains the usable partial result when available.
Variables
Class fields (var).
varos.posix::SocketPair.left_fd
Type
Int@brief`left_fd` field.
@detailsHolds the `left_fd` value for each `SocketPair` instance. The field type is `Int`, and constructors and methods keep it synchronized with the object's runtime state.
var left_fd: Int;
/*
@brief `right_fd` field.varos.posix::SocketPair.right_fd
Type
Int@brief`right_fd` field.
@detailsHolds the `right_fd` value for each `SocketPair` instance. The field type is `Int`, and constructors and methods keep it synchronized with the object's runtime state.
var right_fd: Int;
/*
@brief `closed_left` field.varos.posix::SocketPair.closed_left
Type
Bool@brief`closed_left` field.
@detailsHolds the `closed_left` value for each `SocketPair` instance. The field type is `Bool`, and constructors and methods keep it synchronized with the object's runtime state.
var closed_left: Bool;
/*
@brief `closed_right` field.varos.posix::SocketPair.closed_right
Type
Bool@brief`closed_right` field.
@detailsHolds the `closed_right` value for each `SocketPair` instance. The field type is `Bool`, and constructors and methods keep it synchronized with the object's runtime state.
var closed_right: Bool;
/*varos.posix::Mapping.handle
Type
Int@brief`handle` field.
@detailsStores the underlying runtime handle. The field type is `Int`, and it is maintained by the constructors and methods of `Mapping`.
var handle: Int;
/*
@brief `writable` field.varos.posix::Mapping.writable
Type
Bool@brief`writable` field.
@detailsHolds the `writable` value for each `Mapping` instance. The field type is `Bool`, and constructors and methods keep it synchronized with the object's runtime state.
var writable: Bool;
/*
@brief `closed` field.varos.posix::Mapping.closed
Type
Bool@brief`closed` field.
@detailsIndicates whether the resource has already been closed. The field type is `Bool`, and it is maintained by the constructors and methods of `Mapping`.
var closed_left: Bool;
/*
@brief `closed_right` field.