# ProcessMonitor
<span class="source-link">[[Source]](src/process/process_monitor.md#L-0-200)</span>

Monitors a running child process: forwards its STDOUT/STDERR to a
`ProcessNotify`, writes to its STDIN, and reports its exit status once it
exits. Create one with `StartProcess`.

Exit is detected from a native per-platform event (a pidfd on Linux), not
from the child's pipes reaching end-of-file, so a child that leaves a
grandchild holding its stdout/stderr open is still reported as exited
promptly.


```pony
actor tag ProcessMonitor is
  AsioEventNotify tag
```

#### Implements

* [AsioEventNotify](builtin-AsioEventNotify.md) tag

---

## Public Behaviours

### print
<span class="source-link">[[Source]](src/process/process_monitor.md#L-0-280)</span>


Print some bytes and append a newline.


```pony
be print(
  data: ByteSeq)
```
#### Parameters

*   data: [ByteSeq](builtin-ByteSeq.md)

---

### write
<span class="source-link">[[Source]](src/process/process_monitor.md#L-0-289)</span>


Write to STDIN of the child process.


```pony
be write(
  data: ByteSeq)
```
#### Parameters

*   data: [ByteSeq](builtin-ByteSeq.md)

---

### printv
<span class="source-link">[[Source]](src/process/process_monitor.md#L-0-297)</span>


Print an iterable collection of ByteSeqs.


```pony
be printv(
  data: ByteSeqIter val)
```
#### Parameters

*   data: [ByteSeqIter](builtin-ByteSeqIter.md) val

---

### writev
<span class="source-link">[[Source]](src/process/process_monitor.md#L-0-308)</span>


Write an iterable collection of ByteSeqs.


```pony
be writev(
  data: ByteSeqIter val)
```
#### Parameters

*   data: [ByteSeqIter](builtin-ByteSeqIter.md) val

---

### done_writing
<span class="source-link">[[Source]](src/process/process_monitor.md#L-0-318)</span>


Signal that we are finished writing to STDIN. Once any pending writes have
drained, STDIN is closed so a child waiting on EOF can proceed.


```pony
be done_writing()
```

---

### dispose
<span class="source-link">[[Source]](src/process/process_monitor.md#L-0-330)</span>


Terminate the child and stop monitoring. The exit status of the killed
child is reported through `ProcessNotify.dispose` once its exit event
fires.


```pony
be dispose()
```

---

## Public Functions

### expect
<span class="source-link">[[Source]](src/process/process_monitor.md#L-0-350)</span>


A `stdout` call on the notifier must contain exactly `qty` bytes. If
`qty` is zero, the call can contain any amount of data.


```pony
fun ref expect(
  qty: USize val = 0)
: None val
```
#### Parameters

*   qty: [USize](builtin-USize.md) val = 0

#### Returns

* [None](builtin-None.md) val

---

