W3cubDocs

/Pony

ProcessMonitor

[Source]

Fork+execs / creates a child process and monitors it. Notifies a client about STDOUT / STDERR events.

actor tag ProcessMonitor

Constructors

create

[Source]

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^

Parameters

Returns

Public Behaviours

print

[Source]

Print some bytes and append a newline.

be print(
  data: (String val | Array[U8 val] val))

Parameters

write

[Source]

Write to STDIN of the child process.

be write(
  data: (String val | Array[U8 val] val))

Parameters

printv

[Source]

Print an iterable collection of ByteSeqs.

be printv(
  data: ByteSeqIter val)

Parameters

writev

[Source]

Write an iterable collection of ByteSeqs.

be writev(
  data: ByteSeqIter val)

Parameters

done_writing

[Source]

Set the _done_writing flag to true. If _pending is empty we can close the _stdin pipe.

be done_writing()

dispose

[Source]

Terminate child and close down everything.

be dispose()

timer_notify

[Source]

Windows IO polling timer has fired

be timer_notify()

Public Functions

expect

[Source]

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

Parameters

Returns

Private Behaviours

_event_notify

[Source]

Handle the incoming Asio event from one of the pipes.

be _event_notify(
  event: Pointer[AsioEvent val] tag,
  flags: U32 val,
  arg: U32 val)

Parameters

_read_again

[Source]

Resume reading on file descriptor.

be _read_again(
  near_fd: U32 val)

Parameters

  • near_fd: U32 val

Private Functions

_close

[Source]

Close all pipes and wait for the child process to exit.

fun ref _close()
: None val

Returns

_try_shutdown

[Source]

If neither stdout nor stderr are open we close down and exit.

fun ref _try_shutdown()
: None val

Returns

_pending_reads

[Source]

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

Parameters

Returns

_read_buf_size

[Source]

fun ref _read_buf_size()
: None val

Returns

_write_final

[Source]

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

Parameters

Returns

_pending_writes

[Source]

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

Returns

© 2016-2018, The Pony Developers
© 2014-2015, Causality Ltd.
Licensed under the BSD 2-Clause License.
https://stdlib.ponylang.io/process-ProcessMonitor