The Assimilation Project
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
misc.h File Reference

Defines miscellaneous interfaces. More...

#include <projectcommon.h>
#include <configcontext.h>
#include <syslog.h>
#include <stdio.h>
Include dependency graph for misc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define STD_PID_DIR   "/var/run"
 

Enumerations

enum  PidRunningStat { PID_NOTRUNNING, PID_DEAD, PID_NOTUS, PID_RUNNING }
 Status of pid file and/or running processes referred to by it - analogous to "service status". More...
 

Functions

char * proj_get_sysname (void)
 Return a malloced string of the system name. More...
 
WINEXPORT char * get_default_pid_fileName (const char *procname)
 Make a daemon process out of this process. More...
 
WINEXPORT void daemonize_me (gboolean stay_in_foreground, const char *dirtorunin, char *pidfile)
 pathname of pid file, or NULL More...
 
WINEXPORT void assimilation_openlog (const char *logname)
 Open logs in our style (syslog) More...
 
WINEXPORT PidRunningStat are_we_already_running (const char *pidfile, int *pid)
 Determine service status. More...
 
WINEXPORT guint pidrunningstat_to_status (PidRunningStat)
 Convert PidRunningStat to an exit code for status. More...
 
gboolean create_pid_file (const char *pidfile)
 Create pid file - return TRUE on success. More...
 
WINEXPORT void remove_pid_file (const char *pidfile)
 Remove pid file we created (if we created one) More...
 
WINEXPORT int kill_pid_service (const char *pidfile, int signal)
 Issue given signal to the pidfile-indicated running process. More...
 
void rmpid_and_exit_on_signal (const char *pidfile, int signal)
 Issue given signal to the pidfile-indicated running process. More...
 
WINEXPORT gchar ** assim_merge_environ (const gchar *const *env, ConfigContext *)
 Create new env merged from ConfigContext. More...
 
WINEXPORT void assim_free_environ (gchar **env)
 Free environment created by assim_merge_environ. More...
 
WINEXPORT gsize setpipebuf (int fd, gsize bufsize)
 Set pipe buffer size (if possible) More...
 
WINEXPORT gsize getpipebuf (int fd)
 Return pipe buffer size. More...
 

Variables

const char * assim_syslogid
 

Detailed Description

Defines miscellaneous interfaces.

Defines a variety of miscellaneous non-class interfaces.

This file is part of the Assimilation Project.

Author
Copyright © 2012 - Alan Robertson alanr.nosp@m.@uni.nosp@m.x.sh
The Assimilation software is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The Assimilation software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with the Assimilation Project software. If not, see http://www.gnu.org/licenses/

Definition in file misc.h.

Macro Definition Documentation

#define STD_PID_DIR   "/var/run"

Definition at line 32 of file misc.h.

Referenced by get_default_pid_fileName().

Enumeration Type Documentation

Status of pid file and/or running processes referred to by it - analogous to "service status".

Enumerator
PID_NOTRUNNING 
PID_DEAD 
PID_NOTUS 
PID_RUNNING 

Definition at line 37 of file misc.h.

Function Documentation

WINEXPORT PidRunningStat are_we_already_running ( const char *  pidfile,
int *  pidarg 
)

Determine service status.

Parameters
pidfileThe pathname of our expected pid file
pidargPid of the process (if running)

Definition at line 298 of file misc.c.

References MAXPATH, PID_DEAD, PID_NOTRUNNING, PID_NOTUS, PID_RUNNING, PROCOTHEREXE, PROCSELFEXE, and SEP.

Referenced by create_pid_file(), daemonize_me(), kill_pid_service(), cma.cma::main(), and main().

Here is the caller graph for this function:

WINEXPORT void assim_free_environ ( gchar **  env)

Free environment created by assim_merge_environ.

Parameters
envThe result of assim_merge_environ – to be freed

Definition at line 676 of file misc.c.

Referenced by childprocess_new().

Here is the caller graph for this function:

WINEXPORT gchar** assim_merge_environ ( const gchar *const *  env,
ConfigContext update 
)

Create new env merged from ConfigContext.

Parameters
envInitial environment – or NULL
updateUpdates to merge into this environment

Definition at line 543 of file misc.c.

References _shell_array_value(), _NetAddr::baseclass, CFG_ARRAY, CFG_BOOL, CFG_EEXIST, CFG_INT64, CFG_NETADDR, CFG_STRING, FMT_64BIT, g_get_environ(), _ConfigContext::getaddr, _ConfigContext::getarray, _ConfigContext::getbool, _ConfigContext::getint, _ConfigContext::getstring, _ConfigContext::gettype, _ConfigContext::keycount, _ConfigContext::keys, and _AssimObj::toString.

Referenced by childprocess_new().

Here is the call graph for this function:

Here is the caller graph for this function:

WINEXPORT void assimilation_openlog ( const char *  logname)

Open logs in our style (syslog)

Definition at line 192 of file misc.c.

References assim_syslogid, and assimilation_logger().

Referenced by assimilation_logger(), cma.cma::main(), and main().

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean create_pid_file ( const char *  pidfile)

Create pid file - return TRUE on success.

Definition at line 401 of file misc.c.

References __FUNCTION__, are_we_already_running(), g_unlink, GETPID, PID_DEAD, PID_NOTUS, and PID_RUNNING.

Referenced by daemonize_me().

Here is the call graph for this function:

Here is the caller graph for this function:

WINEXPORT void daemonize_me ( gboolean  stay_in_foreground,
const char *  dirtorunin,
char *  pidfile 
)

pathname of pid file, or NULL

pathname of pid file, or NULL

Make us into a proper daemon.

Parameters
[in]stay_in_foregroundTRUE to not make a background job
[in]dirtoruninDirectory to cd to or NULL for default (/)
[in]pidfilePathname of pidfile or NULL for no pidfile

Definition at line 90 of file misc.c.

References __FUNCTION__, are_we_already_running(), create_pid_file(), DIMOF, and PID_RUNNING.

Referenced by cma.cma::main(), and main().

Here is the call graph for this function:

Here is the caller graph for this function:

WINEXPORT char* get_default_pid_fileName ( const char *  procname)

Make a daemon process out of this process.

Definition at line 448 of file misc.c.

References STD_PID_DIR.

Referenced by main().

Here is the caller graph for this function:

WINEXPORT gsize getpipebuf ( int  fd)

Return pipe buffer size.

Definition at line 710 of file misc.c.

Referenced by setpipebuf().

Here is the caller graph for this function:

WINEXPORT int kill_pid_service ( const char *  pidfile,
int  signal 
)

Issue given signal to the pidfile-indicated running process.

Definition at line 470 of file misc.c.

References are_we_already_running(), g_unlink, and PID_RUNNING.

Referenced by cma.cma::main(), and main().

Here is the call graph for this function:

Here is the caller graph for this function:

WINEXPORT guint pidrunningstat_to_status ( PidRunningStat  )

Convert PidRunningStat to an exit code for status.

Definition at line 520 of file misc.c.

References PID_DEAD, PID_NOTRUNNING, PID_NOTUS, and PID_RUNNING.

Referenced by cma.cma::main(), and main().

Here is the caller graph for this function:

char* proj_get_sysname ( void  )

Return a malloced string of the system name.

Referenced by construct_pcap_frameset(), nano_initiate_shutdown(), and nano_reqconfig().

Here is the caller graph for this function:

WINEXPORT void remove_pid_file ( const char *  pidfile)

Remove pid file we created (if we created one)

Definition at line 461 of file misc.c.

References g_unlink.

Referenced by cma.cma::main(), and main().

Here is the caller graph for this function:

void rmpid_and_exit_on_signal ( const char *  pidfile,
int  signal_in 
)

Issue given signal to the pidfile-indicated running process.

Definition at line 493 of file misc.c.

References catch_pid_signal(), and signal.

Referenced by cma.cma::main().

Here is the call graph for this function:

Here is the caller graph for this function:

WINEXPORT gsize setpipebuf ( int  fd,
gsize  bufsize 
)

Set pipe buffer size (if possible)

Definition at line 684 of file misc.c.

References getpipebuf().

Here is the call graph for this function:

Variable Documentation

const char* assim_syslogid

Definition at line 51 of file misc.c.

Referenced by assimilation_logger(), and assimilation_openlog().