xdasd_unix.c File Reference

OpenXDAS Unix console/daemon functionality. More...

#include "xdasd_main.h"
#include "xdasd_log.h"
#include "xdasd_cmdline.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <signal.h>
#include <unistd.h>

Go to the source code of this file.

Functions

static int xdasd_check_pid (const char *pidfile)
 Check a pid file to see if xdasd is already running.
static int xdasd_write_pid (const char *pidfile, pid_t pid)
 Write a pid file.
static int xdasd_daemonize (void)
 Convert this process to a console-detached daemon.
static void xdasd_signal_handler (int signum)
 Handles all registered signals from the system.
static int xdasd_setup_signal_handler (void)
 Configures signal handlers for the process.
int main (int argc, char **argv)
 The main program entry point.


Detailed Description

OpenXDAS Unix console/daemon functionality.

Author:
John Calcote (jcalcote@novell.com)
Attention:
Please submit patches to http://openxdas.sourceforge.net

Definition in file xdasd_unix.c.


Function Documentation

int main ( int  argc,
char **  argv 
)

The main program entry point.

Parameters:
[in] argc - the number of arguments in argv.
[in] argv - an array of argument string pointers.
Returns:
Zero on success or non-zero on failure.

For internal use only.

Definition at line 197 of file xdasd_unix.c.

References XDASCmdLine_tag::detach, XDASCmdLine_tag::runpath, xdasd_check_pid(), xdasd_daemonize(), xdasd_fatal(), xdasd_main_init(), xdasd_main_run(), xdasd_parse_cmdline(), XDASD_PIDFNAME, xdasd_setup_signal_handler(), and xdasd_write_pid().

static int xdasd_check_pid ( const char *  pidfile  )  [static]

Check a pid file to see if xdasd is already running.

The pid file contains the PID of the process that is already running.

Parameters:
[in] pidfile - the name of a file to read.
Returns:
Zero on success or a non-zero value with errno set on failure.

For internal use only.

Definition at line 66 of file xdasd_unix.c.

Referenced by main().

static int xdasd_daemonize ( void   )  [static]

Convert this process to a console-detached daemon.

Turn the calling process into a daemon (detach from tty setuid(), etc).

Returns:
Zero on success, or a non-zero value if xdasd could not daemonize (or if xdasd is already running).

For internal use only.

Definition at line 114 of file xdasd_unix.c.

Referenced by main().

static int xdasd_setup_signal_handler ( void   )  [static]

Configures signal handlers for the process.

Configures the process to receive SIGALRM, SIGTERM, SIGHUP, SIGPIPE.

Returns:
Zero on success, or a non-zero value on failure.

For internal use only.

Definition at line 166 of file xdasd_unix.c.

References xdasd_signal_handler().

Referenced by main().

static void xdasd_signal_handler ( int  signum  )  [static]

Handles all registered signals from the system.

Get in, get out - fast.

Parameters:
[in] signum - the signal number to handle.

For internal use only.

Definition at line 148 of file xdasd_unix.c.

References xdasd_set_signal(), XDASD_SIGALRM, XDASD_SIGHUP, and XDASD_SIGTERM.

Referenced by xdasd_setup_signal_handler().

static int xdasd_write_pid ( const char *  pidfile,
pid_t  pid 
) [static]

Write a pid file.

Parameters:
[in] pidfile - the name of the file to write.
[in] pid - the PID value to write to pidfile.
Returns:
Zero on success, or -1 with errno set on failure.

For internal use only.

Definition at line 93 of file xdasd_unix.c.

Referenced by main().


Generated on Thu Aug 20 22:33:07 2009 for OpenXDAS by  doxygen 1.5.6