summaryrefslogtreecommitdiffstats
path: root/src/OSSupport/StartAsService.h
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2021-04-21 17:07:48 +0200
committerGitHub <noreply@github.com>2021-04-21 17:07:48 +0200
commit1100b04b59b461f1a2cc3dfe7b53b5473daa7992 (patch)
treeef38a4a731e0c03c6f923708bac0249560ab611f /src/OSSupport/StartAsService.h
parentResets ticks alive on death (#5197) (diff)
downloadcuberite-1100b04b59b461f1a2cc3dfe7b53b5473daa7992.tar
cuberite-1100b04b59b461f1a2cc3dfe7b53b5473daa7992.tar.gz
cuberite-1100b04b59b461f1a2cc3dfe7b53b5473daa7992.tar.bz2
cuberite-1100b04b59b461f1a2cc3dfe7b53b5473daa7992.tar.lz
cuberite-1100b04b59b461f1a2cc3dfe7b53b5473daa7992.tar.xz
cuberite-1100b04b59b461f1a2cc3dfe7b53b5473daa7992.tar.zst
cuberite-1100b04b59b461f1a2cc3dfe7b53b5473daa7992.zip
Diffstat (limited to '')
-rw-r--r--src/OSSupport/StartAsService.h20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/OSSupport/StartAsService.h b/src/OSSupport/StartAsService.h
index 472184367..fe078f303 100644
--- a/src/OSSupport/StartAsService.h
+++ b/src/OSSupport/StartAsService.h
@@ -1,19 +1,17 @@
-#pragma once
+// StartAsService.h
+// Handles startup as a Windows Service or UNIX daemon.
+// This file MUST NOT be included from anywhere other than main.cpp.
-#ifdef _WIN32
-
-#include <csignal>
-
-
+#ifdef _WIN32
-class cStartAsService
+class StartAsService
{
public:
@@ -79,7 +77,7 @@ private:
return;
}
- const auto LastComponent = wcsrchr(applicationFilename, L'\\');
+ const auto LastComponent = std::wcsrchr(applicationFilename, L'\\');
if (LastComponent == nullptr)
{
serviceSetState(0, SERVICE_STOPPED, E_UNEXPECTED);
@@ -89,7 +87,7 @@ private:
const auto LengthToLastComponent = LastComponent - applicationFilename;
// Strip off the filename, keep only the path:
- wcsncpy(applicationDirectory, applicationFilename, LengthToLastComponent);
+ std::wcsncpy(applicationDirectory, applicationFilename, LengthToLastComponent);
applicationDirectory[LengthToLastComponent] = L'\0'; // Make sure new path is null terminated
// Services are run by the SCM, and inherit its working directory - usually System32.
@@ -115,7 +113,7 @@ private:
char * MultibyteArgV[] = { MultibyteArgV0 };
const auto OutputSize = std::size(MultibyteArgV0);
- const auto TranslateResult = wcstombs(MultibyteArgV0, argv[0], OutputSize);
+ const auto TranslateResult = std::wcstombs(MultibyteArgV0, argv[0], OutputSize);
if (TranslateResult == static_cast<size_t>(-1))
{
@@ -141,7 +139,7 @@ private:
#else
-struct cStartAsService
+struct StartAsService
{
/** Make a UNIX daemon. */
template <auto>