Scroll to navigation

DAEMON(3) Manual del Programador de Linux DAEMON(3)

NOMBRE

daemon - ejecución en segundo plano

SINOPSIS

#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)

DESCRIPCIÓN

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.

VALOR DEVUELTO

(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).

ATRIBUTOS

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

CONFORME A

Not in POSIX.1. A similar function appears on the BSDs. The daemon() function first appeared in 4.4BSD.

NOTAS

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.

ERRORES

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.

VÉASE TAMBIÉN

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

COLOFÓN

Esta página es parte de la versión 5.10 del proyecto Linux man-pages. Puede encontrar una descripción del proyecto, información sobre cómo informar errores y la última versión de esta página en https://www.kernel.org/doc/man-pages/.

TRADUCCIÓN

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>..

26 Noviembre 2017 GNU