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

# dexec.h(3)

Contains a robust API for running sub processes with STDOUT and STDERR redirected to syslog.

## NAME

dexec.h - Contains a robust API for running sub processes with STDOUT and STDERR redirected to syslog.

## SYNOPSIS

`#include <stdarg.h>`\

### Macros

\#define **DAEMON\_EXEC\_AVAILABLE**   1\
 This variable is defined to 1 iff **daemon\_exec()** is supported.  #define **DAEMON\_GCC\_SENTINEL**\
 A macro for making use of GCCs printf compilation warnings.  #define **DAEMON\_EXECV\_AVAILABLE**   1\
 This variable is defined to 1 iff **daemon\_execv()** is supported.

### Functions

int **daemon\_exec** (const char \*dir, int \*ret, const char \*prog,...) **DAEMON\_GCC\_SENTINEL**\
 Run the specified executable with the specified arguments in the specified directory and return the return value of the program in the specified pointer.  int **daemon\_execv** (const char \*dir, int \*ret, const char \*prog, va\_list ap)\
 The same as daemon\_exec, but without variadic arguments.

## Detailed Description

Contains a robust API for running sub processes with STDOUT and STDERR redirected to syslog.

Definition in file **dexec.h**.

## Macro Definition Documentation

### #define DAEMON\_EXEC\_AVAILABLE 1

This variable is defined to 1 iff **daemon\_exec()** is supported.

**Since**

0\.4

**See also**

**daemon\_exec()**

Definition at line 39 of file dexec.h.

### #define DAEMON\_EXECV\_AVAILABLE 1

This variable is defined to 1 iff **daemon\_execv()** is supported.

**Since**

0\.11

**See also**

**daemon\_execv()**

Definition at line 68 of file dexec.h.

### #define DAEMON\_GCC\_SENTINEL

A macro for making use of GCCs printf compilation warnings.

Definition at line 45 of file dexec.h.

## Function Documentation

### int daemon\_exec (const char \* dir, int \* ret, const char \* prog, ...)

Run the specified executable with the specified arguments in the specified directory and return the return value of the program in the specified pointer. The calling process is blocked until the child finishes and all child output (either STDOUT or STDIN) has been written to syslog. Running this function requires that daemon\_signal() has been called with SIGCHLD as argument.

**Parameters**

*dir* Working directory for the process. \
 *ret* A pointer to an integer to write the return value of the program to. \
 *prog* The path to the executable \
 *...* The arguments to be passed to the program, followed by a (char \*) NULL

**Returns**

Nonzero on failure, zero on success

**Since**

0\.4

**See also**

**DAEMON\_EXEC\_AVAILABLE**

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

### int daemon\_execv (const char \* dir, int \* ret, const char \* prog, va\_list ap)

The same as daemon\_exec, but without variadic arguments.

**Since**

0\.11

**See also**

**DAEMON\_EXECV\_AVAILABLE**

## Author

Generated automatically by Doxygen for libdaemon from the source code.
