summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
8febc05)
Change to the startup directory before redirecting I/O streams so that
relative paths can be specified. Then change back so we don't tie up
the directory.
/* stderr */\r
if (get_createfile_parameters(key, NSSM_REG_STDERR, path, &sharing, NSSM_STDERR_SHARING, &disposition, NSSM_STDERR_DISPOSITION, &flags, NSSM_STDERR_FLAGS)) return 6;\r
if (path[0]) {\r
/* stderr */\r
if (get_createfile_parameters(key, NSSM_REG_STDERR, path, &sharing, NSSM_STDERR_SHARING, &disposition, NSSM_STDERR_DISPOSITION, &flags, NSSM_STDERR_FLAGS)) return 6;\r
if (path[0]) {\r
+ /* Same as stdout? */\r
if (str_equiv(path, stdout_path)) {\r
/* Two handles to the same file will create a race. */\r
if (! DuplicateHandle(GetCurrentProcess(), si->hStdOutput, GetCurrentProcess(), &si->hStdError, 0, true, DUPLICATE_SAME_ACCESS)) {\r
if (str_equiv(path, stdout_path)) {\r
/* Two handles to the same file will create a race. */\r
if (! DuplicateHandle(GetCurrentProcess(), si->hStdOutput, GetCurrentProcess(), &si->hStdError, 0, true, DUPLICATE_SAME_ACCESS)) {\r
+ /* Change to startup directory in case stdout/stderr are relative paths. */\r
+ TCHAR cwd[MAX_PATH];\r
+ GetCurrentDirectory(_countof(cwd), cwd);\r
+ SetCurrentDirectory(service->dir);\r
+\r
/* Try to get stdout and stderr */\r
if (get_output_handles(key, si)) {\r
log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_GET_OUTPUT_HANDLES_FAILED, service->name, 0);\r
RegCloseKey(key);\r
/* Try to get stdout and stderr */\r
if (get_output_handles(key, si)) {\r
log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_GET_OUTPUT_HANDLES_FAILED, service->name, 0);\r
RegCloseKey(key);\r
+ SetCurrentDirectory(cwd);\r
+ /* Change back in case the startup directory needs to be deleted. */\r
+ SetCurrentDirectory(cwd);\r
+\r
/* Try to get throttle restart delay */\r
override_milliseconds(service->name, key, NSSM_REG_THROTTLE, &service->throttle_delay, NSSM_RESET_THROTTLE_RESTART, NSSM_EVENT_BOGUS_THROTTLE);\r
\r
/* Try to get throttle restart delay */\r
override_milliseconds(service->name, key, NSSM_REG_THROTTLE, &service->throttle_delay, NSSM_RESET_THROTTLE_RESTART, NSSM_EVENT_BOGUS_THROTTLE);\r
\r