iv\_popen(3) ivykis programmer's manual iv\_popen(3)

# [NAME](#NAME)

IV\_POPEN\_REQUEST\_INIT, iv\_popen\_request\_submit, iv\_popen\_request\_close - [**popen**(3)](/man/os/ivykis/popen.3) for ivykis applications

# [SYNOPSIS](#SYNOPSIS)

**#include &lt;iv\_popen.h&gt;**

```
struct iv_popen_request {


        char            *file;


        char            **argv;


        char            *type;
};
```

**void IV\_POPEN\_REQUEST\_INIT(struct iv\_popen\_request \*this);**  
**int iv\_popen\_request\_submit(struct iv\_popen\_request \*this);**  
**void iv\_popen\_request\_close(struct iv\_popen\_request \*this);**

# [DESCRIPTION](#DESCRIPTION)

**iv\_popen** provides [**ivykis**(3)](/man/os/ivykis/ivykis.3) applications with an asynchronous version of [**popen**(3)](/man/os/ivykis/popen.3) that is integrated with the ivykis event loop.

After initialising a **struct iv\_popen\_request** object using **IV\_POPEN\_REQUEST\_INIT** and assigning its **-&gt;file** and **-&gt;argv** and **-&gt;type** members, one can call **iv\_popen\_request\_submit** on it to fork off a child process which will call [**execvp(2)**](/man/os/ivykis/execvp.2) on **-&gt;file** and **-&gt;argv,** while in the parent process returning a file descriptor that is connected to the child's standard input (if **-&gt;type** equals "w") or standard output (if **-&gt;type** equals "r").

When the application is done with the child process, it should call **iv\_popen\_request\_close,** and close the file descriptor returned by **iv\_popen\_request\_submit** (this is not done automatically).

**iv\_popen** will continue to monitor the child's process state while it is running, by registering an [**iv\_wait**(3)](/man/os/ivykis/iv_wait.3) interest for its process ID.

If the child process has not yet terminated when **iv\_popen\_request\_close** is called, **iv\_popen** will attempt to terminate the child process in the background by sending it a series of SIGTERM and SIGKILL signals.

**iv\_popen\_request\_close** must be called from the same thread that **iv\_popen\_request\_submit** was called from on this object.

# [SEE ALSO](#SEE_ALSO)

[**ivykis**(3)](/man/os/ivykis/ivykis.3), [**iv\_wait**(3)](/man/os/ivykis/iv_wait.3), [**execvp**(2)](/man/os/ivykis/execvp.2), [**popen**(3)](/man/os/ivykis/popen.3)

2010-09-04 ivykis

---

Document: iv_popen_request_close(3) from ivykis 0.43.2-r7 (Chainguard OS)
Source: https://github.com/buytenh/ivykis
