The Assimilation Project  based on Assimilation version 0.5.1427809010
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules 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 , int minclosefd);
51 WINEXPORT void assimilation_openlog(const char* logname);
52 WINEXPORT PidRunningStat are_we_already_running(const char * pidfile, int* pid);
54 gboolean create_pid_file(const char * pidfile);
55 WINEXPORT void remove_pid_file(const char * pidfile);
56 WINEXPORT int kill_pid_service(const char * pidfile, int signal);
57 WINEXPORT void rmpid_and_exit_on_signal(const char * pidfile, int signal);
58 WINEXPORT gchar** assim_merge_environ(const gchar *const* env, ConfigContext*);
59 WINEXPORT void assim_free_environ(gchar ** env);
60 WINEXPORT gsize setpipebuf(int fd, gsize bufsize);
61 WINEXPORT gsize getpipebuf(int fd);
62 WINEXPORT void assim_g_notify_unref(gpointer assimobj);
63 WINEXPORT guint assim_set_io_watch(int fd, GIOCondition condition, GIOFunc func, gpointer user_data);
64 
65 WINEXPORT
66 #endif /* MISC_H */
67 
WINEXPORT PidRunningStat are_we_already_running(const char *pidfile, int *pid)
Determine service status.
Definition: misc.c:303
Definition: misc.h:39
WINEXPORT void assim_free_environ(gchar **env)
Free environment created by assim_merge_environ.
Definition: misc.c:681
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:197
WINEXPORT void daemonize_me(gboolean stay_in_foreground, const char *dirtorunin, char *pidfile, int minclosefd)
minimum file descriptor to close - or zero
Definition: misc.c:91
WINEXPORT gchar ** assim_merge_environ(const gchar *const *env, ConfigContext *)
Create new env merged from ConfigContext.
Definition: misc.c:548
const char * procname
process name
Definition: nanoprobe.c:111
WINEXPORT gsize setpipebuf(int fd, gsize bufsize)
Set pipe buffer size (if possible)
Definition: misc.c:689
WINEXPORT guint assim_set_io_watch(int fd, GIOCondition condition, GIOFunc func, gpointer user_data)
Simiplified interface to g_io_add_watch for our Python code.
Definition: misc.c:737
WINEXPORT gsize getpipebuf(int fd)
Return pipe buffer size.
Definition: misc.c:715
#define WINEXPORT
Definition: projectcommon.h:45
gboolean create_pid_file(const char *pidfile)
Create pid file - return TRUE on success.
Definition: misc.c:406
int signal
Definition: childprocess.c:238
WINEXPORT void assim_g_notify_unref(gpointer assimobj)
Unref for glib notify.
Definition: misc.c:725
WINEXPORT int kill_pid_service(const char *pidfile, int signal)
Issue given signal to the pidfile-indicated running process.
Definition: misc.c:475
tuple GIOFunc
Definition: glib.py:72
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
WINEXPORT void rmpid_and_exit_on_signal(const char *pidfile, int signal)
Issue given signal to the pidfile-indicated running process.
Definition: misc.c:498
WINEXPORT void remove_pid_file(const char *pidfile)
Remove pid file we created (if we created one)
Definition: misc.c:466
WINEXPORT guint pidrunningstat_to_status(PidRunningStat)
Convert PidRunningStat to an exit code for status.
Definition: misc.c:525
WINEXPORT char * get_default_pid_fileName(const char *procname)
Make a daemon process out of this process.
Definition: misc.c:453