return false;
}
- if(!strchr(program_name, '\\')) {
- GetCurrentDirectory(sizeof command - 1, command + 1);
- strncat(command, "\\", sizeof command - strlen(command));
- }
-
- strncat(command, program_name, sizeof command - strlen(command));
+ HMODULE module = GetModuleHandle(NULL);
+ GetModuleFileName(module, command + 1, sizeof command - 1);
+ command[sizeof command - 1] = 0;
strncat(command, "\"", sizeof command - strlen(command));
if(do_detach) {
#ifndef HAVE_MINGW
- if(daemon(0, 0)) {
+ if(daemon(1, 0)) {
logger(DEBUG_ALWAYS, LOG_ERR, "Couldn't detach from terminal: %s", strerror(errno));
return false;
}
#endif
}
- logmode = use_logfile?LOGMODE_FILE:LOGMODE_SYSLOG;
- if(do_detach && !use_syslog)
+ if(use_logfile)
+ logmode = LOGMODE_FILE;
+ else if(use_syslog || do_detach)
+ logmode = LOGMODE_SYSLOG;
+ else
logmode = LOGMODE_STDERR;
+
openlogger(identname, logmode);
logger(DEBUG_ALWAYS, LOG_NOTICE, "tincd %s (%s %s) starting, debug level %d",
- VERSION, BUILD_DATE, BUILD_TIME, debug_level);
+ BUILD_VERSION, BUILD_DATE, BUILD_TIME, debug_level);
return true;
}