syslog-ng source
gprocess.h File Reference
#include "syslog-ng.h"
#include <sys/types.h>
#include <glib.h>
Include dependency graph for gprocess.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define g_process_enable_cap(cap)
 
#define g_process_cap_save()   NULL
 
#define g_process_cap_restore(cap)   cap = cap
 

Typedefs

typedef gpointer cap_t
 

Enumerations

enum  GProcessMode { G_PM_FOREGROUND , G_PM_BACKGROUND , G_PM_SAFE_BACKGROUND }
 

Functions

void g_process_set_mode (GProcessMode mode)
 
GProcessMode g_process_get_mode (void)
 
void g_process_set_name (const gchar *name)
 
void g_process_set_user (const gchar *user)
 
void g_process_set_group (const gchar *group)
 
void g_process_set_chroot (const gchar *chroot)
 
void g_process_set_pidfile (const gchar *pidfile)
 
void g_process_set_pidfile_dir (const gchar *pidfile_dir)
 
void g_process_set_working_dir (const gchar *cwd)
 
void g_process_disable_caps (void)
 
void g_process_set_caps (const gchar *caps)
 
void g_process_set_argv_space (gint argc, gchar **argv)
 
void g_process_set_use_fdlimit (gboolean use)
 
void g_process_set_check (gint check_period, gboolean(*check_fn)(void))
 
gboolean g_process_check_cap_syslog (void)
 
void g_process_start (void)
 
void g_process_startup_failed (guint ret_num, gboolean may_exit)
 
void g_process_startup_ok (void)
 
void g_process_finish (void)
 
void g_process_add_option_group (GOptionContext *ctx)
 

Macro Definition Documentation

◆ g_process_cap_restore

#define g_process_cap_restore (   cap)    cap = cap

◆ g_process_cap_save

#define g_process_cap_save ( )    NULL

◆ g_process_enable_cap

#define g_process_enable_cap (   cap)

Typedef Documentation

◆ cap_t

typedef gpointer cap_t

Enumeration Type Documentation

◆ GProcessMode

Enumerator
G_PM_FOREGROUND 
G_PM_BACKGROUND 
G_PM_SAFE_BACKGROUND 

Function Documentation

◆ g_process_add_option_group()

void g_process_add_option_group ( GOptionContext *  ctx)

◆ g_process_check_cap_syslog()

gboolean g_process_check_cap_syslog ( void  )

◆ g_process_disable_caps()

void g_process_disable_caps ( void  )

◆ g_process_finish()

void g_process_finish ( void  )

g_process_finish:

This is a public API function to be called by the user code when the daemon exits after properly initialized (e.g. when it terminates because of SIGTERM). This function currently only removes the PID file.

There is a memory leak for **environ and elements that should be freed here theoretically.

The reason why environ is copied during g_process_set_argv_space so to be able to overwrite process title in ps/top commands to supervisor. In bsd there is setproctitle call which solve this, but currently it is not available for linux.

The problem is that modules can add their own env variables to the list, which must not be freed here, otherwise it would result double free (e.g some version of Oracle Java). One might also would try to track which environment variables are added by syslog-ng, and free only those. There is still a problem with this, **environ itself cannot be freed in some cases. For example libcurl registers an atexit function which needs an environment variable, that would be freed here before at_exit is called, resulting in invalid read.

As this leak does not cause any real problem like accumulating over time, it is safe to leave it as it is.

◆ g_process_get_mode()

GProcessMode g_process_get_mode ( void  )

g_process_get_mode:

Return the processing mode applied to the daemon.

◆ g_process_set_argv_space()

void g_process_set_argv_space ( gint  argc,
gchar **  argv 
)

g_process_set_argv_space: @argc: Original argc, as received by the main function in it's first parameter @argv: Original argv, as received by the main function in it's second parameter

This function should be called by the daemon if it wants to enable process title manipulation in the supervisor process.

◆ g_process_set_caps()

void g_process_set_caps ( const gchar *  caps)

g_process_set_caps: @caps: capability specification in text form

This function should be called by the daemon to set the initial capability set. The process will change its capabilities to this value during startup, provided it has enough permissions to do so.

◆ g_process_set_check()

void g_process_set_check ( gint  check_period,
gboolean(*)(void)  check_fn 
)

g_process_set_check: @check_period: check period in seconds @check_fn: checker function

Installs a checker function that is called at the specified rate. The checked process is allowed to run as long as this function returns TRUE.

◆ g_process_set_chroot()

void g_process_set_chroot ( const gchar *  chroot_dir)

g_process_set_chroot: @chroot_dir: the name of the chroot directory the process should switch to during startup

This function should be called by the daemon to set the chroot directory

◆ g_process_set_group()

void g_process_set_group ( const gchar *  group)

g_process_set_group: @group: the name of the group the process should switch to during startup

This function should be called by the daemon to set the group name.

◆ g_process_set_mode()

void g_process_set_mode ( GProcessMode  mode)

g_process_set_mode: @mode: an element from ZProcessMode

This function should be called by the daemon to set the processing mode as specified by @mode.

◆ g_process_set_name()

void g_process_set_name ( const gchar *  name)

◆ g_process_set_pidfile()

void g_process_set_pidfile ( const gchar *  pidfile)

g_process_set_pidfile: @pidfile: the name of the complete pid file with full path

This function should be called by the daemon to set the PID file name to store the pid of the process. This value will be used as the pidfile directly, neither name nor pidfile_dir influences the pidfile location if this is set.

◆ g_process_set_pidfile_dir()

void g_process_set_pidfile_dir ( const gchar *  pidfile_dir)

g_process_set_pidfile_dir: @pidfile_dir: name of the pidfile directory

This function should be called by the daemon to set the PID file directory. This value is not used if set_pidfile() was called.

◆ g_process_set_use_fdlimit()

void g_process_set_use_fdlimit ( gboolean  use)

◆ g_process_set_user()

void g_process_set_user ( const gchar *  user)

g_process_set_user: @user: the name of the user the process should switch to during startup

This function should be called by the daemon to set the user name.

◆ g_process_set_working_dir()

void g_process_set_working_dir ( const gchar *  cwd)

g_process_set_working_dir: @working_dir: name of the working directory

This function should be called by the daemon to set the working directory. The process will change its current directory to this value or to pidfile_dir if it is unset.

◆ g_process_start()

void g_process_start ( void  )

g_process_start:

Start the process as directed by the options set by various g_process_set_*() functions.

◆ g_process_startup_failed()

void g_process_startup_failed ( guint  ret_num,
gboolean  may_exit 
)

g_process_startup_failed: @ret_num: exit code @may_exit: whether to exit the process

This is a public API function to be called by the user code when initialization failed.

◆ g_process_startup_ok()

void g_process_startup_ok ( void  )

g_process_startup_ok:

This is a public API function to be called by the user code when initialization was successful, we can report back to the user.