or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

builtins.mdconcurrency.mddata-processing.mddevelopment.mdessential-stdlib.mdindex.mdnetworking.mdsecurity.mdsystem-os.md
tile.json

system-os.mddocs/

System and OS Integration

Operating system interface, file system operations, process management, and platform-specific functionality.

Capabilities

OS Interface (Extended)

Extended operating system interface beyond basic file operations.

import os

# Process management
def fork() -> int: ...  # Unix only
def getpid() -> int: ...
def getppid() -> int: ...
def getpgrp() -> int: ...
def setpgrp() -> None: ...
def getuid() -> int: ...  # Unix only
def setuid(uid: int) -> None: ...  # Unix only
def getgid() -> int: ...  # Unix only
def setgid(gid: int) -> None: ...  # Unix only
def getgroups() -> list: ...  # Unix only
def setgroups(groups: list) -> None: ...  # Unix only

# File permissions and ownership
def chmod(path: str, mode: int) -> None: ...
def chown(path: str, uid: int, gid: int) -> None: ...  # Unix only
def lchown(path: str, uid: int, gid: int) -> None: ...  # Unix only
def access(path: str, mode: int) -> bool: ...
def umask(mask: int) -> int: ...

# File system operations
def link(src: str, dst: str) -> None: ...
def symlink(src: str, dst: str, target_is_directory: bool = False) -> None: ...
def readlink(path: str) -> str: ...
def unlink(path: str) -> None: ...
def utime(path: str, times: tuple = None) -> None: ...
def truncate(path: str, length: int) -> None: ...
def sync() -> None: ...  # Unix only

# Directory operations  
def scandir(path: str = '.') -> list: ...
def getcwdb() -> bytes: ...
def chroot(path: str) -> None: ...  # Unix only

# Process execution
def execl(path: str, arg0: str, *args: str) -> None: ...
def execle(path: str, arg0: str, *args: str, env: dict) -> None: ...
def execlp(file: str, arg0: str, *args: str) -> None: ...
def execlpe(file: str, arg0: str, *args: str, env: dict) -> None: ...
def execv(path: str, args: list) -> None: ...
def execve(path: str, args: list, env: dict) -> None: ...
def execvp(file: str, args: list) -> None: ...
def execvpe(file: str, args: list, env: dict) -> None: ...
def _exit(status: int) -> None: ...
def waitpid(pid: int, options: int) -> tuple: ...  # Unix only
def wait() -> tuple: ...  # Unix only

# Signal handling (Unix)
def kill(pid: int, sig: int) -> None: ...  # Unix only
def killpg(pgid: int, sig: int) -> None: ...  # Unix only

# File descriptor operations
def open(path: str, flags: int, mode: int = 0o777) -> int: ...
def close(fd: int) -> None: ...
def read(fd: int, n: int) -> bytes: ...
def write(fd: int, data: bytes) -> int: ...
def lseek(fd: int, pos: int, how: int) -> int: ...
def dup(fd: int) -> int: ...
def dup2(fd: int, fd2: int) -> int: ...
def pipe() -> tuple: ...
def mkfifo(path: str, mode: int = 0o666) -> None: ...  # Unix only

# Terminal operations
def isatty(fd: int) -> bool: ...
def ttyname(fd: int) -> str: ...  # Unix only
def ctermid() -> str: ...  # Unix only

# Random data
def urandom(n: int) -> bytes: ...

# OS constants
O_RDONLY: int     # Open for reading only
O_WRONLY: int     # Open for writing only  
O_RDWR: int       # Open for reading and writing
O_APPEND: int     # Open for append
O_CREAT: int      # Create file if it doesn't exist
O_EXCL: int       # Fail if file exists
O_TRUNC: int      # Truncate file to zero length

F_OK: int         # Test for existence
R_OK: int         # Test for read permission
W_OK: int         # Test for write permission
X_OK: int         # Test for execute permission

SEEK_SET: int     # Seek from beginning
SEEK_CUR: int     # Seek from current position
SEEK_END: int     # Seek from end

# Process exit codes
EX_OK: int = 0
EX_USAGE: int = 64
EX_DATAERR: int = 65
EX_NOINPUT: int = 66
EX_NOUSER: int = 67
EX_NOHOST: int = 68
EX_UNAVAILABLE: int = 69
EX_SOFTWARE: int = 70
EX_OSERR: int = 71
EX_OSFILE: int = 72
EX_CANTCREAT: int = 73
EX_IOERR: int = 74
EX_TEMPFAIL: int = 75
EX_PROTOCOL: int = 76
EX_NOPERM: int = 77
EX_CONFIG: int = 78

# Directory entry class
class DirEntry:
    @property
    def name(self) -> str: ...
    @property
    def path(self) -> str: ...
    def inode(self) -> int: ...
    def is_dir(self, follow_symlinks: bool = True) -> bool: ...
    def is_file(self, follow_symlinks: bool = True) -> bool: ...
    def is_symlink(self) -> bool: ...
    def stat(self, follow_symlinks: bool = True) -> stat_result: ...

Time and Timing

Time-related functions for measuring performance and scheduling.

import time

# Time measurement
def time() -> float: ...
def time_ns() -> int: ...
def monotonic() -> float: ...
def monotonic_ns() -> int: ...
def perf_counter() -> float: ...
def perf_counter_ns() -> int: ...
def process_time() -> float: ...
def process_time_ns() -> int: ...
def thread_time() -> float: ...
def thread_time_ns() -> int: ...

# Sleep and delay
def sleep(secs: float) -> None: ...

# Time conversion
def gmtime(secs: float = None) -> struct_time: ...
def localtime(secs: float = None) -> struct_time: ...
def mktime(t: struct_time) -> float: ...
def asctime(t: struct_time = None) -> str: ...
def ctime(secs: float = None) -> str: ...
def strftime(format: str, t: struct_time = None) -> str: ...
def strptime(string: str, format: str) -> struct_time: ...

# Timezone
def tzname() -> tuple: ...
def timezone() -> int: ...
def daylight() -> int: ...
def tzset() -> None: ...

# struct_time class
class struct_time:
    tm_year: int     # Year (e.g. 1993)
    tm_mon: int      # Month (1-12)
    tm_mday: int     # Day (1-31)
    tm_hour: int     # Hour (0-23)
    tm_min: int      # Minute (0-59)
    tm_sec: int      # Second (0-61)
    tm_wday: int     # Weekday (0-6, Monday is 0)
    tm_yday: int     # Day of year (1-366)
    tm_isdst: int    # Daylight saving time flag (-1, 0, 1)

Platform Information

Detailed platform and system information retrieval.

import platform

# System information
def system() -> str: ...           # OS name (Linux, Windows, Darwin, etc.)
def node() -> str: ...             # Network name
def release() -> str: ...          # OS release version
def version() -> str: ...          # OS version
def machine() -> str: ...          # Machine type (x86_64, ARM, etc.)
def processor() -> str: ...        # Processor name

# Platform details
def platform(aliased: bool = False, terse: bool = False) -> str: ...
def uname() -> uname_result: ...
def architecture(executable: str = '', bits: str = '', linkage: str = '') -> tuple: ...

# Python information
def python_version() -> str: ...
def python_version_tuple() -> tuple: ...
def python_branch() -> str: ...
def python_revision() -> str: ...
def python_build() -> tuple: ...
def python_compiler() -> str: ...
def python_implementation() -> str: ...

# Java information (Jython)
def java_ver() -> tuple: ...

# Windows information
def win32_ver(release: str = '', version: str = '', csd: str = '', ptype: str = '') -> tuple: ...
def win32_edition() -> str: ...
def win32_is_iot() -> bool: ...

# Mac information  
def mac_ver(release: str = '', versioninfo: tuple = ('', '', ''), machine: str = '') -> tuple: ...

# Linux information
def libc_ver(executable: str = '', lib: str = '', version: str = '', chunksize: int = 16384) -> tuple: ...
def freedesktop_os_release() -> dict: ...

# Unix result tuple
class uname_result:
    system: str      # Operating system name
    node: str        # Network name
    release: str     # Operating system release
    version: str     # Operating system version  
    machine: str     # Hardware identifier
    processor: str   # Processor identifier

Signal Handling (Unix)

Signal handling for Unix-like systems.

import signal

# Signal registration
def signal(signalnum: int, handler) -> object: ...
def alarm(time: int) -> int: ...
def pause() -> None: ...
def getsignal(signalnum: int) -> object: ...

# Signal masks (Unix)
def pthread_sigmask(how: int, mask: set) -> set: ...
def sigpending() -> set: ...
def sigwait(sigset: set) -> int: ...
def sigwaitinfo(sigset: set) -> struct_siginfo_t: ...
def sigtimedwait(sigset: set, timeout: float) -> struct_siginfo_t: ...

# Signal sets
def sigfillset() -> set: ...
def sigemptyset() -> set: ...

# Constants for common signals
SIGHUP: int = 1      # Hangup
SIGINT: int = 2      # Interrupt (Ctrl+C)
SIGQUIT: int = 3     # Quit
SIGILL: int = 4      # Illegal instruction
SIGABRT: int = 6     # Abort
SIGFPE: int = 8      # Floating point exception
SIGKILL: int = 9     # Kill (cannot be caught)
SIGSEGV: int = 11    # Segmentation fault
SIGPIPE: int = 13    # Broken pipe
SIGALRM: int = 14    # Alarm clock
SIGTERM: int = 15    # Termination
SIGUSR1: int = 30    # User-defined signal 1
SIGUSR2: int = 31    # User-defined signal 2
SIGCHLD: int = 17    # Child status changed
SIGCONT: int = 18    # Continue
SIGSTOP: int = 19    # Stop (cannot be caught)
SIGTSTP: int = 20    # Terminal stop (Ctrl+Z)

# Special handlers
SIG_DFL: object      # Default signal handler
SIG_IGN: object      # Ignore signal handler

# Signal mask operations
SIG_BLOCK: int       # Block signals
SIG_UNBLOCK: int     # Unblock signals
SIG_SETMASK: int     # Set signal mask

# Signal info structure
class struct_siginfo_t:
    si_signo: int    # Signal number
    si_code: int     # Signal code
    si_errno: int    # Error number
    si_pid: int      # Process ID
    si_uid: int      # User ID
    si_status: int   # Exit status
    si_band: int     # Band event

Resource Management (Unix)

System resource limits and usage information.

import resource

# Resource usage
def getrusage(who: int) -> struct_rusage: ...
def getrlimit(resource: int) -> tuple: ...
def setrlimit(resource: int, limits: tuple) -> None: ...
def getpagesize() -> int: ...

# Resource constants
RUSAGE_SELF: int     # Current process
RUSAGE_CHILDREN: int # Child processes
RUSAGE_THREAD: int   # Current thread

RLIMIT_CPU: int      # CPU time in seconds
RLIMIT_FSIZE: int    # Maximum file size
RLIMIT_DATA: int     # Maximum heap size
RLIMIT_STACK: int    # Maximum stack size
RLIMIT_CORE: int     # Maximum core file size
RLIMIT_RSS: int      # Maximum resident set size
RLIMIT_NPROC: int    # Maximum number of processes
RLIMIT_NOFILE: int   # Maximum number of open files
RLIMIT_OFILE: int    # Maximum number of open files (BSD)
RLIMIT_MEMLOCK: int  # Maximum locked memory
RLIMIT_VMEM: int     # Maximum virtual memory size
RLIMIT_AS: int       # Maximum address space size

RLIM_INFINITY: int   # Infinite limit

# Resource usage structure
class struct_rusage:
    ru_utime: float      # User time used
    ru_stime: float      # System time used
    ru_maxrss: int       # Maximum resident set size
    ru_ixrss: int        # Integral shared memory size
    ru_idrss: int        # Integral unshared data size
    ru_isrss: int        # Integral unshared stack size
    ru_minflt: int       # Page reclaims
    ru_majflt: int       # Page faults
    ru_nswap: int        # Swaps
    ru_inblock: int      # Block input operations
    ru_oublock: int      # Block output operations
    ru_msgsnd: int       # Messages sent
    ru_msgrcv: int       # Messages received
    ru_nsignals: int     # Signals received
    ru_nvcsw: int        # Voluntary context switches
    ru_nivcsw: int       # Involuntary context switches

Memory Mapping (Unix)

Memory-mapped file support for efficient file I/O.

import mmap

class mmap:
    def __init__(self, fileno: int, length: int, flags: int = MAP_SHARED, 
                 prot: int = PROT_WRITE | PROT_READ, access=None, offset: int = 0) -> None: ...
    
    # File-like methods
    def read(self, n: int = None) -> bytes: ...
    def read_byte(self) -> int: ...
    def readline(self) -> bytes: ...
    def write(self, bytes: bytes) -> int: ...
    def write_byte(self, byte: int) -> None: ...
    def flush(self, offset: int = 0, size: int = 0) -> None: ...
    def close(self) -> None: ...
    
    # Sequence methods
    def __getitem__(self, index) -> int: ...
    def __setitem__(self, index, value: int) -> None: ...
    def __len__(self) -> int: ...
    
    # Memory operations
    def find(self, sub: bytes, start: int = 0, end: int = None) -> int: ...
    def rfind(self, sub: bytes, start: int = 0, end: int = None) -> int: ...
    def seek(self, pos: int, whence: int = 0) -> None: ...
    def tell(self) -> int: ...
    def move(self, dest: int, src: int, count: int) -> None: ...
    def resize(self, newsize: int) -> None: ...
    def size(self) -> int: ...
    
    @property
    def closed(self) -> bool: ...

# Memory protection flags
PROT_READ: int       # Pages may be read
PROT_WRITE: int      # Pages may be written
PROT_EXEC: int       # Pages may be executed

# Memory mapping flags
MAP_SHARED: int      # Share changes
MAP_PRIVATE: int     # Private copy-on-write mapping

# Access modes
ACCESS_READ: int     # Read-only access
ACCESS_WRITE: int    # Write-through access
ACCESS_COPY: int     # Copy-on-write access

# Page allocation
ALLOCATIONGRANULARITY: int  # Windows allocation granularity
PAGESIZE: int               # System page size

Types

OS Types

# File descriptor type
FileDescriptor = int

# Process ID type
ProcessID = int

# File mode/permissions
FileMode = int  # Octal permissions (e.g., 0o644, 0o755)

# Signal number
SignalNumber = int

# Environment variable type
Environment = dict[str, str]

# Path-like types
PathLike = str | bytes | os.PathLike

# Wait status
WaitStatus = int  # Process wait status

Time Types

# Timestamp types
Timestamp = float      # Seconds since epoch
TimestampNS = int     # Nanoseconds since epoch

# Time tuple for broken-down time
TimeTuple = tuple[int, int, int, int, int, int, int, int, int]  # 9-element tuple

Platform Types

# Platform identification
PlatformSystem = str    # 'Linux', 'Windows', 'Darwin', etc.
PlatformMachine = str   # 'x86_64', 'AMD64', 'arm64', etc.
PlatformProcessor = str # Processor description string

# Version information
VersionInfo = tuple[str, ...]  # Version components

Resource Types

# Resource limit tuple
ResourceLimit = tuple[int, int]  # (soft_limit, hard_limit)

# Resource usage values
ResourceValue = int | float  # Resource measurement value

Memory Map Types

# Memory access patterns
MemoryAccess = int  # ACCESS_READ, ACCESS_WRITE, ACCESS_COPY

# Memory protection flags
MemoryProtection = int  # PROT_READ, PROT_WRITE, PROT_EXEC

# Memory mapping flags  
MemoryMapping = int  # MAP_SHARED, MAP_PRIVATE