X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fprocess.c;h=f2fff1dc6d0446c0ab36c66921b74e26995dcc99;hp=01ebe494ba7c79b0ab2cc62cb0b5c2454da2537f;hb=8c3105283ac53f8cc9cc4dde25957ec1cf6b53a0;hpb=4c85542894f7fca823b119b05e07179deb24229a diff --git a/src/process.c b/src/process.c index 01ebe494..f2fff1dc 100644 --- a/src/process.c +++ b/src/process.c @@ -43,7 +43,9 @@ extern char **g_argv; extern bool use_logfile; extern volatile bool running; +#ifndef HAVE_MINGW sigset_t emptysigset; +#endif static int saved_debug_level = -1; @@ -103,13 +105,18 @@ bool install_service(void) { command, NULL, NULL, NULL, NULL, NULL); if(!service) { - logger(LOG_ERR, "Could not create %s service: %s", identname, winerror(GetLastError())); - return false; + DWORD lasterror = GetLastError(); + logger(LOG_ERR, "Could not create %s service: %s", identname, winerror(lasterror)); + if(lasterror != ERROR_SERVICE_EXISTS) + return false; } - ChangeServiceConfig2(service, SERVICE_CONFIG_DESCRIPTION, &description); - - logger(LOG_INFO, "%s service installed", identname); + if(service) { + ChangeServiceConfig2(service, SERVICE_CONFIG_DESCRIPTION, &description); + logger(LOG_INFO, "%s service installed", identname); + } else { + service = OpenService(manager, identname, SERVICE_ALL_ACCESS); + } if(!StartService(service, 0, NULL)) logger(LOG_WARNING, "Could not start %s service: %s", identname, winerror(GetLastError()));