X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fprocess.c;h=5e7b1db5979ca627d10d1567e9a0ca2abaafee31;hb=ca7502b6de1e1ae49a62ad6b7a7ae8b760fa51ff;hp=f3e190c29c47bc21fdc3dd29dd875b48127ada0e;hpb=a29e6b49ef7a184941ab8cda2de9487744a82f83;p=tinc diff --git a/src/process.c b/src/process.c index f3e190c2..5e7b1db5 100644 --- a/src/process.c +++ b/src/process.c @@ -25,7 +25,7 @@ #include "process.h" #include "version.h" -#ifdef HAVE_MINGW +#ifdef HAVE_WINDOWS #include "utils.h" #endif @@ -33,12 +33,16 @@ bool do_detach = true; extern char **g_argv; -extern bool use_logfile; -extern bool use_syslog; + +/* If nonzero, use syslog instead of stderr in no-detach mode. */ +bool use_syslog = false; + +/* If nonzero, write log entries to a separate file. */ +bool use_logfile = false; /* Some functions the less gifted operating systems might lack... */ -#ifdef HAVE_MINGW +#ifdef HAVE_WINDOWS static SC_HANDLE manager = NULL; static SC_HANDLE service = NULL; static SERVICE_STATUS status = {0}; @@ -46,7 +50,8 @@ static SERVICE_STATUS_HANDLE statushandle = 0; static bool install_service(void) { char command[4096] = "\""; - SERVICE_DESCRIPTION description = {"Virtual Private Network daemon"}; + char description_buffer[] = "Virtual Private Network daemon"; + SERVICE_DESCRIPTION description = {description_buffer}; manager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); @@ -107,7 +112,7 @@ static bool install_service(void) { io_t stop_io; -DWORD WINAPI controlhandler(DWORD request, DWORD type, LPVOID data, LPVOID context) { +static DWORD WINAPI controlhandler(DWORD request, DWORD type, LPVOID data, LPVOID context) { (void)type; (void)data; (void)context; @@ -141,7 +146,7 @@ DWORD WINAPI controlhandler(DWORD request, DWORD type, LPVOID data, LPVOID conte return NO_ERROR; } -VOID WINAPI run_service(DWORD argc, LPTSTR *argv) { +static VOID WINAPI run_service(DWORD argc, LPTSTR *argv) { extern int main2(int argc, char **argv); status.dwServiceType = SERVICE_WIN32; @@ -197,7 +202,7 @@ bool init_service(void) { bool detach(void) { logmode_t logmode; -#ifndef HAVE_MINGW +#ifndef HAVE_WINDOWS signal(SIGPIPE, SIG_IGN); signal(SIGUSR1, SIG_IGN); signal(SIGUSR2, SIG_IGN); @@ -207,7 +212,7 @@ bool detach(void) { #endif if(do_detach) { -#ifndef HAVE_MINGW +#ifndef HAVE_WINDOWS if(daemon(1, 0)) { logger(DEBUG_ALWAYS, LOG_ERR, "Couldn't detach from terminal: %s", strerror(errno));