---
name: "iv_signal"
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_signal"
---

# iv\_signal(3)

ivykis signal handling

## NAME

IV\_SIGNAL\_INIT, iv\_signal\_register, iv\_signal\_unregister - ivykis signal handling

## SYNOPSIS

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

```
struct iv_signal {
        int             signum;
        unsigned int    flags;
        void            *cookie;
        void            (*handler)(void *);
};
```

**void IV\_SIGNAL\_INIT(struct iv\_signal \****this***);**\
 **int iv\_signal\_register(struct iv\_signal \****this***);**\
 **void iv\_signal\_unregister(struct iv\_signal \****this***);**\

## DESCRIPTION

**iv\_signal** provides a way for [**ivykis**(3)](/ivykis/3.md) applications to handle POSIX signals, by integrating them with the ivykis event loop.

An ivykis application desiring signal notification registers a **struct iv\_signal** object by calling **iv\_signal\_register,** after having initialised it with **IV\_SIGNAL\_INIT** and subsequently having filled in the **-\>signum,** **-\>cookie** and **-\>handler** members.

Once the signal indicated by **-\>signum** is delivered to any thread in the current process, the callback specified by **-\>handler** is scheduled to be called in the thread that the **struct iv\_signal** object was registered in, with **-\>cookie** as its sole argument.

If the same signal arrives again while the callback function is still running, the callback function is guaranteed to be called again after it returns.

It is permitted to register multiple **struct iv\_signal** objects for the same signal number.  If all such objects are registered with **IV\_SIGNAL\_FLAG\_EXCLUSIVE** in **-\>flags** unset, then all objects will have their callback functions called upon arrival of the signal, in no guaranteed order.

Invoking callback functions stops at the first **struct iv\_signal** object with **IV\_SIGNAL\_FLAG\_EXCLUSIVE** in **-\>flags** set, so that if all objects have **IV\_SIGNAL\_FLAG\_EXCLUSIVE** set, only one callback function will be invoked.

To deinitialize a **struct iv\_signal** object, call **iv\_signal\_unregister** from the same thread that **iv\_signal\_register** was called from on that object.

It is permitted to unregister a **struct iv\_signal** object from any ivykis callback function in the thread it was registered in, including from a callback function triggered by this object, and it is permitted to free the memory corresponding to an unregistered object from its own callback function.

It is guaranteed that signals delivered to child processes that were created by [**fork**(2)](/fork/2.md) but that have not yet called [**execve**(2)](/execve/2.md) will not cause **iv\_signal** callbacks to be invoked in the parent process.

Internally, **iv\_signal** is implemented using [**iv\_event\_raw**(3)](/iv_event_raw/3.md).

## SEE ALSO

[**ivykis**(3)](/ivykis/3.md), [**iv\_event\_raw**(3)](/iv_event_raw/3.md), [**sigaction**(2)](/sigaction/2.md)
