Fork+execs / creates a child process and monitors it. Notifies a client about STDOUT / STDERR events.
actor tag ProcessMonitor
Create infrastructure to communicate with a forked child process and register the asio events. Fork child process and notify our user about incoming data via the notifier.
new tag create( auth: (AmbientAuth val | StartProcessAuth val), backpressure_auth: (AmbientAuth val | ApplyReleaseBackpressureAuth val), notifier: ProcessNotify iso, filepath: FilePath val, args: Array[String val] val, vars: Array[String val] val) : ProcessMonitor tag^
Print some bytes and append a newline.
be print( data: (String val | Array[U8 val] val))
Write to STDIN of the child process.
be write( data: (String val | Array[U8 val] val))
Print an iterable collection of ByteSeqs.
be printv( data: ByteSeqIter val)
Write an iterable collection of ByteSeqs.
be writev( data: ByteSeqIter val)
Set the _done_writing flag to true. If _pending is empty we can close the _stdin pipe.
be done_writing()
Terminate child and close down everything.
be dispose()
Windows IO polling timer has fired
be timer_notify()
A stdout
call on the notifier must contain exactly qty
bytes. If qty
is zero, the call can contain any amount of data.
fun ref expect( qty: USize val = 0) : None val
Handle the incoming Asio event from one of the pipes.
be _event_notify( event: Pointer[AsioEvent val] tag, flags: U32 val, arg: U32 val)
Resume reading on file descriptor.
be _read_again( near_fd: U32 val)
Close all pipes and wait for the child process to exit.
fun ref _close() : None val
If neither stdout nor stderr are open we close down and exit.
fun ref _try_shutdown() : None val
Read from stdout or stderr while data is available. If we read 4 kb of data, send ourself a resume message and stop reading, to avoid starving other actors. It's safe to use the same buffer for stdout and stderr because of causal messaging. Events get processed one after another.
fun ref _pending_reads( pipe: _Pipe ref) : None val
fun ref _read_buf_size() : None val
Write as much as possible to the pipe if it is open and there are no pending writes. Save everything unwritten into _pending and apply backpressure.
fun ref _write_final( data: (String val | Array[U8 val] val)) : None val
Send any pending data. If any data can't be sent, keep it in _pending. Once _pending is non-empty, direct writes will get queued there, and they can only be written here. If the _done_writing flag is set, close the pipe once we've processed pending writes.
fun ref _pending_writes() : None val
© 2016-2018, The Pony Developers
© 2014-2015, Causality Ltd.
Licensed under the BSD 2-Clause License.
https://stdlib.ponylang.io/process-ProcessMonitor