- README

- Top Level Namespace
- Adler32
- ArgumentError
- Array
- Atomic
- Base64
  - Error
- Benchmark
  - BM
    - Job
    - Tms
  - IPS
    - Entry
    - Job
- BigFloat
- BigInt
- BigRational
- BitArray
- Bool
- Box
- Bytes
- Channel
  - Buffered
  - ClosedError
  - ReceiveAction
  - SelectAction
  - SendAction
  - Unbuffered
- Char
  - Reader
- Class
- Colorize
  - Object
  - ObjectExtensions
- Comparable
- Complex
- Concurrent
  - CanceledError
- CRC32
- Crypto
  - Bcrypt
    - Error
    - Password
  - Blowfish
  - Subtle
- Crystal
  - Macros
    - And
    - Arg
    - ArrayLiteral
    - Assign
    - ASTNode
    - BinaryOp
    - Block
    - BoolLiteral
    - Call
    - Case
    - Cast
    - CharLiteral
    - ClassDef
    - ClassVar
    - Def
    - Expressions
    - Generic
    - Global
    - HashLiteral
    - If
    - ImplicitObj
    - InstanceSizeOf
    - InstanceVar
    - IsA
    - Macro
    - MacroId
    - MetaVar
    - MultiAssign
    - NamedArgument
    - NamedTupleLiteral
    - NilableCast
    - NilLiteral
    - Nop
    - Not
    - NumberLiteral
    - Or
    - Out
    - Path
    - PointerOf
    - RangeLiteral
    - ReadInstanceVar
    - RegexLiteral
    - Require
    - RespondsTo
    - SizeOf
    - Splat
    - StringInterpolation
    - StringLiteral
    - SymbolLiteral
    - TupleLiteral
    - TypeDeclaration
    - TypeNode
    - UnaryExpression
    - UninitializedVar
    - Union
    - Var
    - VisibilityModifier
    - When
    - While
  - System
- CSV
  - Builder
    - Row
  - Error
  - Lexer
  - MalformedCSVError
  - Parser
  - Row
  - Token
    - Kind
- Debug
  - DWARF
    - Abbrev
      - Attribute
    - AT
    - FORM
    - Info
      - Value
    - LineNumbers
      - Register
      - Row
      - Sequence
    - LNE
    - LNS
    - Strings
    - TAG
  - ELF
    - Endianness
    - Error
    - Ident
    - Klass
    - Machine
    - OSABI
    - SectionHeader
      - Flags
      - Type
    - Type
- Deque
- Digest
  - Base
  - MD5
  - SHA1
- Dir
- DivisionByZero
- DL
- ECR
- Enum
- Enumerable
  - EmptyError
- ENV
- Errno
- Exception
- Fiber
- File
  - Stat
- FileUtils
- Flate
  - Error
  - Reader
  - Strategy
  - Writer
- Float
  - Primitive
  - Printer
    - CachedPowers
      - Power
    - DiyFP
    - Grisu3
    - IEEE
- Float32
- Float64
- GC
  - Stats
- Gzip
  - Error
  - Header
  - Reader
  - Writer
- Hash
- HTML
- HTTP
  - Client
    - BodyType
    - Response
  - CompressHandler
  - ComputedContentTypeHeader
  - Cookie
  - Cookies
  - ErrorHandler
  - FormData
    - Builder
    - Error
    - FileMetadata
    - Parser
    - Part
  - Handler
    - Proc
  - Headers
  - LogHandler
  - Multipart
    - Builder
    - Error
    - Parser
  - Params
    - Builder
  - Request
  - Server
    - Context
    - RequestProcessor
    - Response
  - StaticFileHandler
    - DirectoryListing
  - WebSocket
  - WebSocketHandler
- Indexable
- IndexError
- INI
- Int
  - Primitive
  - Signed
  - Unsigned
- Int16
- Int32
- Int64
- Int8
- InvalidByteSequenceError
- IO
  - Buffered
  - ByteFormat
    - BigEndian
    - LittleEndian
    - NetworkEndian
    - SystemEndian
  - Delimited
  - EncodingOptions
  - EOFError
  - Error
  - FileDescriptor
  - Hexdump
  - Memory
  - MultiWriter
  - Seek
  - Sized
  - Timeout
- IPSocket
- Iterable
- Iterator
  - IteratorWrapper
  - Stop
- JSON
  - Any
  - Builder
    - ArrayState
    - DocumentEndState
    - DocumentStartState
    - ObjectState
    - StartState
    - State
  - Error
  - Lexer
  - ParseException
  - Parser
  - PullParser
  - Token
  - Type
- KeyError
- Levenshtein
  - Finder
- LLVM
  - ABI
    - AArch64
    - ArgKind
    - ArgType
    - ARM
    - FunctionType
    - X86
    - X86_64
      - RegClass
  - AtomicOrdering
  - AtomicRMWBinOp
  - Attribute
  - AttributeIndex
  - BasicBlock
  - BasicBlockCollection
  - Builder
  - CallConvention
  - CodeGenFileType
  - CodeGenOptLevel
  - CodeModel
  - Context
  - DIBuilder
  - DIFlags
  - DwarfTag
  - DwarfTypeEncoding
  - Function
  - FunctionCollection
  - FunctionPassManager
    - Runner
  - GenericValue
  - GlobalCollection
  - InstructionCollection
  - IntPredicate
  - JITCompiler
  - Linkage
  - MemoryBuffer
  - Module
  - ModuleFlag
  - ModulePassManager
  - OperandBundleDef
  - ParameterCollection
  - PassManagerBuilder
  - PassRegistry
  - PhiTable
  - RealPredicate
  - RelocMode
  - Target
  - TargetData
  - TargetMachine
  - Type
    - Kind
  - Value
    - Kind
  - ValueMethods
  - VerifierFailureAction
- Logger
  - Formatter
  - Severity
- Markdown
  - HTMLRenderer
  - Parser
    - PrefixHeader
    - UnorderedList
  - Renderer
- Math
- Mutex
- NamedTuple
- Nil
- Number
  - Primitive
- OAuth
  - AccessToken
  - Consumer
  - Error
  - RequestToken
- OAuth2
  - AccessToken
    - Bearer
    - Mac
  - Client
  - Error
  - Session
- Object
- OpenSSL
  - Digest
    - Error
    - UnsupportedError
  - DigestBase
  - DigestIO
    - DigestMode
  - Error
  - HMAC
  - MD5
  - SHA1
  - SSL
    - Context
      - Client
      - Server
    - Error
    - ErrorType
    - Modes
    - Options
    - Socket
      - Client
      - Server
    - VerifyMode
    - X509VerifyFlags
- OptionParser
  - Exception
  - InvalidOption
  - MissingOption
- PartialComparable
- Pointer
  - Appender
- PrettyPrint
- Proc
- Process
  - Env
  - Status
  - Stdio
  - Tms
- Random
  - ISAAC
  - MT19937
  - PCG32
  - System
- Range
- Readline
  - CompletionProc
  - KeyBindingProc
- Reference
- Reflect
- Regex
  - MatchData
  - Options
- SecureRandom
- Set
- Signal
- Slice
- Socket
  - Address
  - Addrinfo
  - Error
  - Family
  - IPAddress
  - Protocol
  - Server
  - Type
  - UNIXAddress
- Spec
  - Expectations
  - Methods
  - ObjectExtensions
- StaticArray
- String
  - Builder
  - RawConverter
- StringPool
- StringScanner
- Struct
- Symbol
- System
- TCPServer
- TCPSocket
- Tempfile
- Termios
  - AttributeSelection
  - BaudRate
  - ControlMode
  - InputMode
  - LineControl
  - LocalMode
  - OutputMode
- Time
  - DayOfWeek
  - EpochConverter
  - EpochMillisConverter
  - Format
    - Error
  - Kind
  - MonthSpan
  - Span
- Tuple
- TypeCastError
- UDPSocket
- UInt16
- UInt32
- UInt64
- UInt8
- Unicode
  - CaseOptions
- Union
- UNIXServer
- UNIXSocket
- URI
  - Error
- Value
- WeakRef
- XML
  - Attributes
  - AttributeType
  - Builder
  - Error
  - HTMLParserOptions
  - Namespace
  - Node
  - NodeSet
  - ParserOptions
  - Reader
  - SaveOptions
  - Type
  - XPathContext
- YAML
  - Any
  - Builder
  - Error
  - EventKind
  - ParseException
  - Parser
  - PullParser
  - Type
- Zip
  - CompressionMethod
  - Error
  - File
    - Entry
  - FileInfo
  - Reader
    - Entry
  - Writer
    - Entry
- Zlib
  - Error
  - Reader
  - Writer

# class Process

- Process
- Reference
- Object

## Defined in:

## Constant Summary

PATH_DELIMITER = `{% if flag?(:windows) %} ';' {% else %} ':' {% end %}`

## Constructors

- .fork : self?

  Duplicates the current process.

- .new(command : String, args = nil, env : Env = nil, clear_env : Bool = false, shell : Bool = false, input : Stdio = false, output : Stdio = false, error : Stdio = false, chdir : String? = nil)

  Creates a process, executes it, but doesn't wait for it to complete.

## Class Method Summary

- .after_fork_child_callbacks

  Hooks are defined here due to load order problems.

- .exec(command : String, args = nil, env : Env = nil, clear_env : Bool = false, shell : Bool = false, input : Bool | IO::FileDescriptor = true, output : Bool | IO::FileDescriptor = true, error : Bool | IO::FileDescriptor = true, chdir : String? = nil)

  Replaces the current process with a new one.

- .executable_path

  Returns an absolute path to the executable file of the currently running program.

- .exists?(pid : Int)

  Returns `true` if the process identified by pid is valid for a currently registered process, `false` otherwise.

- .exit(status = 0)

  Terminate the current process immediately.

- .find_executable(name, path = ENV["PATH"]?, pwd = Dir.current)

  Searches an executable, checking for an absolute path, a path relative to pwd or absolute path, then eventually searching in directories declared in path.

- .fork(&block)

  Runs the given block inside a new process and returns a `Process` representing the new child process.

- .kill(signal : Signal, *pids : Int)

  Sends a signal to the processes identified by the given pids.

- .pgid : LibC::PidT

  Returns the process group identifier of the current process.

- .pgid(pid : Int32) : LibC::PidT

  Returns the process group identifier of the process identified by pid.

- .pid : LibC::PidT

  Returns the process identifier of the current process.

- .ppid : LibC::PidT

  Returns the process identifier of the parent process of the current process.

- .run(command : String, args = nil, env : Env = nil, clear_env : Bool = false, shell : Bool = false, input : Stdio = false, output : Stdio = false, error : Stdio = false, chdir : String? = nil) : Process::Status

  Executes a process and waits for it to complete.

- .run(command : String, args = nil, env : Env = nil, clear_env : Bool = false, shell : Bool = false, input : Stdio = nil, output : Stdio = nil, error : Stdio = nil, chdir : String? = nil, &block)

  Executes a process, yields the block, and then waits for it to finish.

- .times : Tms

  Returns a `Tms` for the current process.

## Instance Method Summary

- #close

  Closes any pipes to the child process.

- #error

  A pipe to this process's error.

- #error? : IO::FileDescriptor?

  A pipe to this process's error.

- #exists?

  Whether the process is still registered in the system.

- #input

  A pipe to this process's input.

- #input? : IO::FileDescriptor?

  A pipe to this process's input.

- #kill(sig = Signal::TERM)

  See also: `Process.kill`

- #output

  A pipe to this process's output.

- #output? : IO::FileDescriptor?

  A pipe to this process's output.

- #pid : Int32
- #terminated?

  Whether this process is already terminated.

- #wait : Process::Status

  Waits for this process to complete and closes any pipes.

### Instance methods inherited from class `Reference`

==(other : self)
==(other) ==, dup dup, hash hash, inspect(io : IO) : Nil inspect, object_id : UInt64 object_id, pretty_print(pp) : Nil pretty_print, same?(other : Reference)
same?(other : Nil) same?, to_s(io : IO) : Nil to_s

### Constructor methods inherited from class `Reference`

new new

### Instance methods inherited from class `Object`

!=(other) !=, !~(other) !~, ==(other) ==, ===(other : JSON::Any)
===(other : YAML::Any)
===(other) ===, =~(other) =~, class class, dup dup, hash hash, inspect(io : IO)
inspect inspect, itself itself, not_nil! not_nil!, pretty_inspect(width = 79, newline = "\n", indent = 0) : String pretty_inspect, pretty_print(pp : PrettyPrint) : Nil pretty_print, tap(&block) tap, to_json(io : IO)
to_json to_json, to_pretty_json(indent : String = " ")
to_pretty_json(io : IO, indent : String = " ") to_pretty_json, to_s
to_s(io : IO) to_s, to_yaml(io : IO)
to_yaml to_yaml, try(&block) try, unsafe_as(type : T.class) forall T unsafe_as

### Constructor methods inherited from class `Object`

from_json(string_or_io, root : String) : self
from_json(string_or_io) : self from_json, from_yaml(string_or_io) : self from_yaml

## Constructor Detail

def self.fork : self? #

Duplicates the current process. Returns a `Process` representing the new child process in the current process and `nil` inside the new child process.

def self.new(command : String, args = nil, env : Env = nil, clear_env : Bool = false, shell : Bool = false, input : Stdio = false, output : Stdio = false, error : Stdio = false, chdir : String? = nil) #

Creates a process, executes it, but doesn't wait for it to complete.

To wait for it to finish, invoke `#wait`.

By default the process is configured without input, output or error.

## Class Method Detail

def self.after_fork_child_callbacks #

Hooks are defined here due to load order problems.

def self.exec(command : String, args = nil, env : Env = nil, clear_env : Bool = false, shell : Bool = false, input : Bool | IO::FileDescriptor = true, output : Bool | IO::FileDescriptor = true, error : Bool | IO::FileDescriptor = true, chdir : String? = nil) #

Replaces the current process with a new one.

The possible values for input, output and error are:

- `false`: no `IO` (`/dev/null`)
- `true`: inherit from parent
- `IO`: use the given `IO`

def self.executable_path #

Returns an absolute path to the executable file of the currently running program. This is in opposition to `PROGRAM_NAME` which may be a relative or absolute path, just the executable file name or a symlink.

The executable path will be canonicalized (all symlinks and relative paths will be expanded).

Returns `nil` if the file can't be found.

def self.exists?(pid : Int) #

Returns `true` if the process identified by pid is valid for a currently registered process, `false` otherwise. Note that this returns `true` for a process in the zombie or similar state.

def self.exit(status = 0) #

Terminate the current process immediately. All open files, pipes and sockets are flushed and closed, all child processes are inherited by PID 1. This does not run any handlers registered with `at_exit`, use `::exit` for that.

status is the exit status of the current process.

def self.find_executable(name, path = ENV["PATH"]?, pwd = Dir.current) #

Searches an executable, checking for an absolute path, a path relative to pwd or absolute path, then eventually searching in directories declared in path.

def self.fork(&block) #

Runs the given block inside a new process and returns a `Process` representing the new child process.

def self.kill(signal : Signal, *pids : Int) #

Sends a signal to the processes identified by the given pids.

def self.pgid : LibC::PidT #

Returns the process group identifier of the current process.

def self.pgid(pid : Int32) : LibC::PidT #

Returns the process group identifier of the process identified by pid.

def self.pid : LibC::PidT #

Returns the process identifier of the current process.

def self.ppid : LibC::PidT #

Returns the process identifier of the parent process of the current process.

def self.run(command : String, args = nil, env : Env = nil, clear_env : Bool = false, shell : Bool = false, input : Stdio = false, output : Stdio = false, error : Stdio = false, chdir : String? = nil) : Process::Status #

Executes a process and waits for it to complete.

By default the process is configured without input, output or error.

def self.run(command : String, args = nil, env : Env = nil, clear_env : Bool = false, shell : Bool = false, input : Stdio = nil, output : Stdio = nil, error : Stdio = nil, chdir : String? = nil, &block) #

Executes a process, yields the block, and then waits for it to finish.

By default the process is configured to use pipes for input, output and error. These will be closed automatically at the end of the block.

Returns the block's value.

def self.times : Tms #

Returns a `Tms` for the current process. For the children times, only those of terminated children are returned.

## Instance Method Detail

def close #

Closes any pipes to the child process.

def error #

A pipe to this process's error. Raises if a pipe wasn't asked when creating the process.

def error? : IO::FileDescriptor? #

A pipe to this process's error. Raises if a pipe wasn't asked when creating the process.

def exists? #

Whether the process is still registered in the system. Note that this returns `true` for processes in the zombie or similar state.

def input #

A pipe to this process's input. Raises if a pipe wasn't asked when creating the process.

def input? : IO::FileDescriptor? #

A pipe to this process's input. Raises if a pipe wasn't asked when creating the process.

def kill(sig = Signal::TERM) #

See also: `Process.kill`

def output #

A pipe to this process's output. Raises if a pipe wasn't asked when creating the process.

def output? : IO::FileDescriptor? #

A pipe to this process's output. Raises if a pipe wasn't asked when creating the process.

def pid : Int32 #
def terminated? #

Whether this process is already terminated.

def wait : Process::Status #

Waits for this process to complete and closes any pipes.