daemon()

run program in background as daemon 

Function


SYNOPSIS

#include <stdlib.h>

int daemon(int nochdir, int noclose);


DESCRIPTION

The daemon() function is for programs wanting to detach themselves from the controlling terminal and run in the background as system daemons.

Note:

Use of this function with the NuTCRACKER Platform is almost certainly incorrect; refer to PORTING ISSUES.


PARAMETERS

nochdir 

Determines whether or not daemon() changes the current working directory to root. When this parameter is non-zero, the directory is not changed; otherwise, it is.

noclose 

Determines whether or not daemon() redirects standard input, standard output, and standard error to /dev/null. When this parameter is non-zero, no redirection occurs; otherwise, it does.


RETURN VALUES

The daemon() function may fail and set errno for any of the errors specified for fork() and setsid().


CONFORMANCE

4.4BSD.


MULTITHREAD SAFETY LEVEL

Unsafe.


PORTING ISSUES

Traditional UNIX-style daemons are not supported on Windows. In their place are processes running as Services. Services have special properties, and are controlled by the Service Control Manager. Please refer to Porting Daemons in the PTC MKS Toolkit UNIX to Windows Porting Guide for information on how to convert your daemon to a Windows Service.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
fork(), setsid()


PTC MKS Toolkit 10.5 Documentation Build 40.