The Assimilation Project  based on Assimilation version
Go to the documentation of this file.
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>
32 #define STD_PID_DIR "/var/run"
34 extern const char* assim_syslogid;
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);
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);
66 #endif /* MISC_H */
WINEXPORT PidRunningStat are_we_already_running(const char *pidfile, int *pid)
Determine service status.
Definition: misc.c:331
Definition: misc.h:39
WINEXPORT void assim_free_environ(gchar **env)
Free environment created by assim_merge_environ.
Definition: misc.c:709
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:225
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:106
WINEXPORT gchar ** assim_merge_environ(const gchar *const *env, ConfigContext *)
Create new env merged from ConfigContext.
Definition: misc.c:576
const char * procname
process name
Definition: nanoprobe.c:113
WINEXPORT gsize setpipebuf(int fd, gsize bufsize)
Set pipe buffer size (if possible)
Definition: misc.c:717
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:765
WINEXPORT gsize getpipebuf(int fd)
Return pipe buffer size.
Definition: misc.c:743
Definition: projectcommon.h:45
gboolean create_pid_file(const char *pidfile)
Create pid file - return TRUE on success.
Definition: misc.c:434
int signal
Definition: childprocess.c:238
WINEXPORT void assim_g_notify_unref(gpointer assimobj)
Unref for glib notify.
Definition: misc.c:753
WINEXPORT int kill_pid_service(const char *pidfile, int signal)
Issue given signal to the pidfile-indicated running process.
Definition: misc.c:503
Project common header file.
Definition: misc.h:40
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:53
WINEXPORT void rmpid_and_exit_on_signal(const char *pidfile, int signal)
Issue given signal to the pidfile-indicated running process.
Definition: misc.c:526
WINEXPORT void remove_pid_file(const char *pidfile)
Remove pid file we created (if we created one)
Definition: misc.c:494
WINEXPORT guint pidrunningstat_to_status(PidRunningStat)
Convert PidRunningStat to an exit code for status.
Definition: misc.c:553
WINEXPORT char * get_default_pid_fileName(const char *procname)
Make a daemon process out of this process.
Definition: misc.c:481