daemon(3) Library Functions Manual daemon(3)

daemon - ejecución en segundo plano

Biblioteca Estándar C (libc, -lc)

#include <unistd.h>
int daemon(int nochdir, int noclose);
Requisitos de Macros de Prueba de Características para glibc (véase feature_test_macros(7)):

daemon():

    Since glibc 2.21:
        _DEFAULT_SOURCE
    In glibc 2.19 and 2.20:
        _DEFAULT_SOURCE || (_XOPEN_SOURCE && _XOPEN_SOURCE < 500)
    Up to and including glibc 2.19:
        _BSD_SOURCE || (_XOPEN_SOURCE && _XOPEN_SOURCE < 500)

La función daemon() es utilizada por programas que desean desvincularse de la terminal de control y correr en segundo plano como demonios de sistema.

If nochdir is zero, daemon() changes the process's current working directory to the root directory ("/"); otherwise, the current working directory is left unchanged.

If noclose is zero, daemon() redirects standard input, standard output, and standard error to /dev/null; otherwise, no changes are made to these file descriptors.

(This function forks, and if the fork(2) succeeds, the parent calls _exit(2), so that further errors are seen by the child only.) On success daemon() returns zero. If an error occurs, daemon() returns -1 and sets errno to any of the errors specified for the fork(2) and setsid(2).

Para obtener una explicación de los términos usados en esta sección, véase attributes(7).

Interfaz Atributo Valor
daemon() Seguridad del hilo Multi-hilo seguro

A similar function appears on the BSDs.

La implementación de glibc puede devolver también -1 cuando /dev/null existe pero no es un dispositivo de caracteres con los números mayor y menor esperados. En este caso errno no necesita ser modificado.

None.

4.4BSD.

The GNU C library implementation of this function was taken from BSD, and does not employ the double-fork technique (i.e., fork(2), setsid(2), fork(2)) that is necessary to ensure that the resulting daemon process is not a session leader. Instead, the resulting daemon is a session leader. On systems that follow System V semantics (e.g., Linux), this means that if the daemon opens a terminal that is not already a controlling terminal for another session, then that terminal will inadvertently become the controlling terminal for the daemon.

fork(2), setsid(2), daemon(7), logrotate(8)

La traducción al español de esta página del manual fue creada por Miguel Pérez Ibars <mpi79470@alu.um.es>

Esta traducción es documentación libre; lea la GNU General Public License Version 3 o posterior con respecto a las condiciones de copyright. No existe NINGUNA RESPONSABILIDAD.

Si encuentra algún error en la traducción de esta página del manual, envíe un correo electrónico a debian-l10n-spanish@lists.debian.org.

31 Octubre 2023 Páginas de manual de Linux 6.06