---
name: "iv_popen_request_close"
section: "3"
platform: "linux"
package: "libivykis-dev"
version: "0.43.2-1+b1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/iv_popen"
---

# iv\_popen\_request\_close(3)

popen(3) for ivykis applications

Part of [iv\_popen(3)](/iv_popen/3.md).

## NAME

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

## SYNOPSIS

**#include \<iv\_popen.h\>**

```
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

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

After initialising a **struct iv\_popen\_request** object using **IV\_POPEN\_REQUEST\_INIT** and assigning its **-\>file** and **-\>argv** and **-\>type** members, one can call **iv\_popen\_request\_submit** on it to fork off a child process which will call **execvp(2)** on **-\>file** and **-\>argv,** while in the parent process returning a file descriptor that is connected to the child's standard input (if **-\>type** equals "w") or standard output (if **-\>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)](/iv_wait/3.md) 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

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