X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fprocess.c;h=5bb7eb3df6da69bdc34c069ec1f9c704642b335e;hb=83fa44ce42c67837dad30ba1538bf1fa8c49a47d;hp=cbc816be5b5667c2100e07f671929cffe7d2c8fc;hpb=120e0567cba17eeb57c12a34686fddbbb491b62f;p=tinc diff --git a/src/process.c b/src/process.c index cbc816be..5bb7eb3d 100644 --- a/src/process.c +++ b/src/process.c @@ -62,12 +62,9 @@ static bool install_service(void) { 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)); @@ -203,7 +200,7 @@ bool detach(void) { 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; }