mirror of
https://bitbucket.org/openhip/openhip/
synced 2023-12-14 05:52:53 +01:00
- use /var/log/hip.log for logfile and /var/run/hip.pid for PID file as
/usr/local/var/* is non-standard - daemonize usermode hip daemon when -d option is specified - note that printf() output from usermode threads is lost until we replace all printf() calls with a logging function git-svn-id: svn://svn.code.sf.net/p/openhip/code/hip/trunk@56 4c5cb64f-9889-4596-9799-84b02dc3effa
This commit is contained in:
parent
c93b35bce0
commit
26bc91b598
|
@ -38,6 +38,12 @@ CFLAGS="$CFLAGS -O3 -Werror -D_GNU_SOURCE -fno-strict-aliasing"
|
|||
|
||||
# HIP files go in /etc/hip or /usr/local/etc/hip
|
||||
sysconfdir=$sysconfdir/hip
|
||||
# HIP state directory for /var/log/hip.log and /var/run/hip.pid
|
||||
if test "$localstatedir" = "\${prefix}/var" ; then
|
||||
# use /var instead of /usr/local/var (/usr/local/var/log isn't standard)
|
||||
localstatedir="/var"
|
||||
fi
|
||||
|
||||
|
||||
# Checks for programs.
|
||||
AC_PROG_CXX
|
||||
|
|
|
@ -71,7 +71,7 @@
|
|||
#define HIP_PUB_SUFFIX "_host_identities.pub.xml"
|
||||
|
||||
#define HIP_LOCK_FILENAME "hip.pid"
|
||||
#define HIP_LOG_FILENAME "hipd.log"
|
||||
#define HIP_LOG_FILENAME "hip.log"
|
||||
|
||||
/*
|
||||
* Implementation limits
|
||||
|
|
|
@ -211,8 +211,9 @@ void init_hip(int ac, char **av)
|
|||
int i;
|
||||
char timestr[26];
|
||||
struct timeval time1;
|
||||
int do_daemon = 0;
|
||||
|
||||
printf("init_hip()\n");
|
||||
/*printf("init_hip()\n");*/
|
||||
|
||||
/* get arguments for hipd */
|
||||
memset(hipd_args, 0, sizeof(hipd_args));
|
||||
|
@ -220,11 +221,13 @@ void init_hip(int ac, char **av)
|
|||
ac--, av++;
|
||||
i = 0;
|
||||
while (ac > 0) {
|
||||
// printf("adding arg: %s\n", *av);
|
||||
/* printf("adding arg: %s\n", *av); */
|
||||
if (i > 0) /* add a space between parameters */
|
||||
hipd_args[i++] = ' ';
|
||||
snprintf(&hipd_args[i], sizeof(hipd_args) - i, "%s", *av);
|
||||
i += strlen(*av);
|
||||
if ((*av)[0] == '-' && (*av)[1] == 'd')
|
||||
do_daemon = 1;
|
||||
av++, ac--;
|
||||
}
|
||||
|
||||
|
@ -232,6 +235,20 @@ void init_hip(int ac, char **av)
|
|||
hip_sadb_init();
|
||||
g_state = 0;
|
||||
|
||||
/*
|
||||
* Run in background as daemon.
|
||||
*/
|
||||
if (do_daemon) {
|
||||
/* Do not fork() later in hipd_main since that is a child
|
||||
* thread. The '-d' option is still passed to hipd_main in
|
||||
* order to log output. Output from the other threads is lost;
|
||||
* they need to be converted from printf() to a logging
|
||||
* function. */
|
||||
printf("Running in background as daemon.\n");
|
||||
if (daemon(0, 0) < 0)
|
||||
fprintf(stderr, "error running as daemon\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Kernel helpers
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue