---
name: "dpid.h"
section: "3"
platform: "linux"
package: "libdaemon-doc"
version: "0.14-7.1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/dpid.h"
---

# dpid.h(3)

Contains an API for manipulating PID files.

## NAME

dpid.h - Contains an API for manipulating PID files.

## SYNOPSIS

`#include <sys/types.h>`\

### Macros

\#define **DAEMON\_PID\_FILE\_KILL\_WAIT\_AVAILABLE**   1\
 This variable is defined to 1 iff **daemon\_pid\_file\_kill\_wait()** is supported.

### Typedefs

typedef const char \*(\* **daemon\_pid\_file\_proc\_t**) (void)\
 Prototype of a function for generating the name of a PID file.

### Functions

const char \* **daemon\_pid\_file\_proc\_default** (void)\
 A function for creating a pid file name from daemon\_pid\_file\_ident.  int **daemon\_pid\_file\_create** (void)\
 Creates PID pid file for the current process.  int **daemon\_pid\_file\_remove** (void)\
 Removes the PID file of the current process.  pid\_t **daemon\_pid\_file\_is\_running** (void)\
 Returns the PID file of a running daemon, if available.  int **daemon\_pid\_file\_kill** (int s)\
 Kills a running daemon, if available.  int **daemon\_pid\_file\_kill\_wait** (int s, int m)\
 Similar to **daemon\_pid\_file\_kill()** but waits until the process died.

### Variables

const char \* **daemon\_pid\_file\_ident**\
 Identification string for the PID file name, only used when daemon\_pid\_file\_proc is set to **daemon\_pid\_file\_proc\_default()**.  **daemon\_pid\_file\_proc\_t** **daemon\_pid\_file\_proc**\
 A function pointer which is used to generate the name of the PID file to manipulate.

## Detailed Description

Contains an API for manipulating PID files.

Definition in file **dpid.h**.

## Macro Definition Documentation

### #define DAEMON\_PID\_FILE\_KILL\_WAIT\_AVAILABLE 1

This variable is defined to 1 iff **daemon\_pid\_file\_kill\_wait()** is supported.

**Since**

0\.3

**See also**

**daemon\_pid\_file\_kill\_wait()**

Definition at line 82 of file dpid.h.

## Typedef Documentation

### typedef const char\*(\* daemon\_pid\_file\_proc\_t) (void)

Prototype of a function for generating the name of a PID file.

Definition at line 37 of file dpid.h.

## Function Documentation

### int daemon\_pid\_file\_create (void)

Creates PID pid file for the current process.

**Returns**

zero on success, nonzero on failure

**Examples** **testd.c**.

### pid\_t daemon\_pid\_file\_is\_running (void)

Returns the PID file of a running daemon, if available.

**Returns**

The PID or negative on failure

**Examples** **testd.c**.

### int daemon\_pid\_file\_kill (int s)

Kills a running daemon, if available.

**Parameters**

*s* The signal to send

**Returns**

zero on success, nonzero on failure

### int daemon\_pid\_file\_kill\_wait (int s, int m)

Similar to **daemon\_pid\_file\_kill()** but waits until the process died. This functions is new in libdaemon 0.3. The macro DAEMON\_PID\_FILE\_KILL\_WAIT\_AVAILABLE is defined iff libdaemon supports this function.

**Parameters**

*s* The signal to send \
 *m* Seconds to wait at maximum

**Returns**

zero on success, nonzero on failure (timeout condition is considered a failure)

**Since**

0\.3

**See also**

**DAEMON\_PID\_FILE\_KILL\_WAIT\_AVAILABLE**

**Examples** **testd.c**.

### const char\* daemon\_pid\_file\_proc\_default (void)

A function for creating a pid file name from daemon\_pid\_file\_ident.

**Returns**

The PID file path

### int daemon\_pid\_file\_remove (void)

Removes the PID file of the current process.

**Returns**

zero on success, nonzero on failure

**Examples** **testd.c**.

## Variable Documentation

### const char\* daemon\_pid\_file\_ident` [extern]`

Identification string for the PID file name, only used when daemon\_pid\_file\_proc is set to **daemon\_pid\_file\_proc\_default()**. Use **daemon\_ident\_from\_argv0()** to generate an identification string from argv\[0\]

**Examples** **testd.c**.

### daemon\_pid\_file\_proc\_t daemon\_pid\_file\_proc` [extern]`

A function pointer which is used to generate the name of the PID file to manipulate. Points to **daemon\_pid\_file\_proc\_default()** by default.

## Author

Generated automatically by Doxygen for libdaemon from the source code.
