---
name: "io_thtrp"
section: "3"
platform: "linux"
package: "libnessus-dev"
version: "1.0.10-2"
release: "Debian 3.0 (Woody)"
platforms: ["linux"]
url: "https://new.carta.tech/io_thtrp"
---

# io\_thtrp(3)

set a trap function to cope with io threads table overfrow

## NAME

io\_thtrp - set a trap function to cope with io threads table overfrow

## SYNOPSIS

```
#include <peks.h>

int io_thtrp (unsigned fd,
              int(*)(void*,unsigned long) trap, void *data,
              int use_pid);
```

## DESCRIPTION

This function installs a trap on the server that is invoked when the client detects an io threads table overflow. This typically happens when a series of server child functions die unexpectedly before destroying the io threads on the receiving client.

On the client, the trap feature is activated while the second function argument is -1 or 1.

The trap function gets a thread id (or a process id) and checks, whether the server part of the io thread is still alive. If so, the trap function returns a non-zero value, otherwise the value 0.

In the latter case, the client is informed to purge the corresponding thread (see **IO\_PURGE\_THREAD** in **[io\_ctrl(3)](/io_ctrl/3.md)**.)

If the second argument *trap* is NULL, the trap is removed. If the argument is 1, or -1, a receiver trap is installed on the receiver but no user defined function will be invoked.

Example (receiver):

```
int n = io_ctrl (socket, IO_MAX_THREADS, 0, 0) ;
/* set the high water mark on 2/3rd of the total of channels */
io_ctrl (socket, IO_HWMBL_THREADS, (n /= 3, &n), 0);
io_thtrp (socket, (int(*)(void*,unsigned long))-1, 0, 1);
...
```

Example (sender):

```
int verify_io_process
  (void      *unused,
   unsigned long pid)
{
/* this function is reliable as super user, only */
return (kill (pid, 0) >= 0 : 1 : 0) ;
}
...

/* install process tracker */
io_thtrp (socket, verify_io_process, 0, 1);
```

## SEE ALSO

[**iostream**(3)](/iostream/3.md), [**io\_ctrl**(3)](/io_ctrl/3.md),  [**io\_push**(3)](/io_push/3.md), [**io\_send**(3)](/io_send/3.md), [**fork**(2)](/fork/2.md),

## AUTHOR

The **peks** package where these functions belong to was written by Jordan Hrycaj \<jordan@teddy-net.com\>, originally to support the **nessus** security scanner.
