The Assimilation Project
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
misc.h
Go to the documentation of this file.
1 
24 #ifndef _MISC_H
25 #include <projectcommon.h>
26 #include <configcontext.h>
27 #ifndef WIN32
28 #include <syslog.h>
29 #endif
30 #include <stdio.h>
31 
32 #define STD_PID_DIR "/var/run"
33 
34 extern const char* assim_syslogid;
35 
37 typedef enum {
38  PID_NOTRUNNING, //< Nothing seems to be running for this pidfile
39  PID_DEAD, //< The pid file exists, but its process doesn't
40  PID_NOTUS, //< Something is running, but we don't think it's one of us
41  PID_RUNNING, //< The pid file exists, and looks like one of us
43 char * proj_get_sysname(void);
44 
47 WINEXPORT void daemonize_me(gboolean stay_in_foreground
48 , const char * dirtorunin
49 , char* pidfile);
50 WINEXPORT void assimilation_openlog(const char* logname);
51 WINEXPORT PidRunningStat are_we_already_running(const char * pidfile, int* pid);
53 gboolean create_pid_file(const char * pidfile);
54 WINEXPORT void remove_pid_file(const char * pidfile);
55 WINEXPORT int kill_pid_service(const char * pidfile, int signal);
56 void rmpid_and_exit_on_signal(const char * pidfile, int signal);
57 WINEXPORT gchar ** assim_merge_environ(const gchar *const* env, ConfigContext*);
58 WINEXPORT void assim_free_environ(gchar ** env);
59 WINEXPORT gsize setpipebuf(int fd, gsize bufsize);
60 WINEXPORT gsize getpipebuf(int fd);
61 WINEXPORT void assim_g_notify_unref(gpointer assimobj);
62 #endif /* MISC_H */
63 
WINEXPORT PidRunningStat are_we_already_running(const char *pidfile, int *pid)
Determine service status.
Definition: misc.c:298
Definition: misc.h:39
WINEXPORT void assim_free_environ(gchar **env)
Free environment created by assim_merge_environ.
Definition: misc.c:676
char * proj_get_sysname(void)
Return a malloced string of the system name.
WINEXPORT void assimilation_openlog(const char *logname)
Open logs in our style (syslog)
Definition: misc.c:192
WINEXPORT gchar ** assim_merge_environ(const gchar *const *env, ConfigContext *)
Create new env merged from ConfigContext.
Definition: misc.c:543
const char * procname
process name
Definition: nanoprobe.c:107
WINEXPORT gsize setpipebuf(int fd, gsize bufsize)
Set pipe buffer size (if possible)
Definition: misc.c:684
WINEXPORT gsize getpipebuf(int fd)
Return pipe buffer size.
Definition: misc.c:710
#define WINEXPORT
Definition: projectcommon.h:45
gboolean create_pid_file(const char *pidfile)
Create pid file - return TRUE on success.
Definition: misc.c:401
int signal
Definition: childprocess.c:238
WINEXPORT void assim_g_notify_unref(gpointer assimobj)
Unref for glib notify.
Definition: misc.c:720
WINEXPORT void daemonize_me(gboolean stay_in_foreground, const char *dirtorunin, char *pidfile)
pathname of pid file, or NULL
Definition: misc.c:90
WINEXPORT int kill_pid_service(const char *pidfile, int signal)
Issue given signal to the pidfile-indicated running process.
Definition: misc.c:470
Project common header file.
Definition: misc.h:40
PidRunningStat
Status of pid file and/or running processes referred to by it - analogous to "service status"...
Definition: misc.h:37
Implements Configuration Context class.
const char * assim_syslogid
Definition: misc.c:51
void rmpid_and_exit_on_signal(const char *pidfile, int signal)
Issue given signal to the pidfile-indicated running process.
Definition: misc.c:493
WINEXPORT void remove_pid_file(const char *pidfile)
Remove pid file we created (if we created one)
Definition: misc.c:461
WINEXPORT guint pidrunningstat_to_status(PidRunningStat)
Convert PidRunningStat to an exit code for status.
Definition: misc.c:520
WINEXPORT char * get_default_pid_fileName(const char *procname)
Make a daemon process out of this process.
Definition: misc.c:448