Tor  0.4.7.0-alpha-dev
Functions | Variables
daemon.c File Reference

Run the tor process in the background (unix only) More...

#include "orconfig.h"
#include "lib/process/daemon.h"
#include "lib/fs/files.h"
#include "lib/log/log.h"
#include "lib/thread/threads.h"
#include <errno.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Functions

bool start_daemon_has_been_called (void)
 
int start_daemon (void)
 
int finish_daemon (const char *desired_cwd)
 

Variables

static int start_daemon_called = 0
 
static int finish_daemon_called = 0
 
static int daemon_filedes [2]
 

Detailed Description

Run the tor process in the background (unix only)

Definition in file daemon.c.

Function Documentation

◆ finish_daemon()

int finish_daemon ( const char *  desired_cwd)

Finish putting the process into daemon mode: drop standard fds, and tell the parent process to exit. (Note: it's safe to call this more than once: calls after the first are ignored. Calls start_daemon first if it hasn't been called already.) Return true if we actually did a fork; false if we didn't.

Definition at line 121 of file daemon.c.

◆ start_daemon()

int start_daemon ( void  )

Start putting the process into daemon mode: fork and drop all resources except standard fds. The parent process never returns, but stays around until finish_daemon is called. (Note: it's safe to call this more than once: calls after the first are ignored.) Return true if we actually forked and this is the child; false otherwise.

Definition at line 58 of file daemon.c.

Referenced by finish_daemon(), and options_act_once_on_startup().

◆ start_daemon_has_been_called()

bool start_daemon_has_been_called ( void  )

Return true iff we've called start_daemon() at least once.

Definition at line 46 of file daemon.c.

Referenced by options_act_once_on_startup().

Variable Documentation

◆ daemon_filedes

int daemon_filedes[2]
static

Socketpair used to communicate between parent and child process while daemonizing.

Definition at line 40 of file daemon.c.

Referenced by start_daemon().

◆ finish_daemon_called

int finish_daemon_called = 0
static

True iff we've called finish_daemon().

Definition at line 37 of file daemon.c.

Referenced by finish_daemon().

◆ start_daemon_called

int start_daemon_called = 0
static

True iff we've called start_daemon().

Definition at line 35 of file daemon.c.

Referenced by finish_daemon(), start_daemon(), and start_daemon_has_been_called().