The Assimilation Project
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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 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 #endif /* MISC_H */
WINEXPORT PidRunningStat are_we_already_running(const char *pidfile, int *pid)
Determine service status.
Definition: misc.c:302
Definition: misc.h:39
WINEXPORT void assim_free_environ(gchar **env)
Free environment created by assim_merge_environ.
Definition: misc.c:680
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:196
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:90
WINEXPORT gchar ** assim_merge_environ(const gchar *const *env, ConfigContext *)
Create new env merged from ConfigContext.
Definition: misc.c:547
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:688
WINEXPORT gsize getpipebuf(int fd)
Return pipe buffer size.
Definition: misc.c:714
Definition: projectcommon.h:45
gboolean create_pid_file(const char *pidfile)
Create pid file - return TRUE on success.
Definition: misc.c:405
int signal
Definition: childprocess.c:238
WINEXPORT void assim_g_notify_unref(gpointer assimobj)
Unref for glib notify.
Definition: misc.c:724
WINEXPORT int kill_pid_service(const char *pidfile, int signal)
Issue given signal to the pidfile-indicated running process.
Definition: misc.c:474
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:51
void rmpid_and_exit_on_signal(const char *pidfile, int signal)
Issue given signal to the pidfile-indicated running process.
Definition: misc.c:497
WINEXPORT void remove_pid_file(const char *pidfile)
Remove pid file we created (if we created one)
Definition: misc.c:465
WINEXPORT guint pidrunningstat_to_status(PidRunningStat)
Convert PidRunningStat to an exit code for status.
Definition: misc.c:524
WINEXPORT char * get_default_pid_fileName(const char *procname)
Make a daemon process out of this process.
Definition: misc.c:452