aboutsummaryrefslogtreecommitdiff
path: root/src/zencore/process.cpp
diff options
context:
space:
mode:
authorLiam Mitchell <[email protected]>2025-08-22 16:12:38 -0700
committerGitHub Enterprise <[email protected]>2025-08-22 16:12:38 -0700
commit207c4a32612891711d9d69466b6dfc653428bb07 (patch)
treed4b8de42a91ee3327b14fc0aa66c92bc3de46555 /src/zencore/process.cpp
parent5.6.18-pre0 (diff)
parentMove windows service utilities to zenutil and fix clang-format errors (diff)
downloadzen-207c4a32612891711d9d69466b6dfc653428bb07.tar.xz
zen-207c4a32612891711d9d69466b6dfc653428bb07.zip
Merge pull request #139 from ue-foundation/de/zen-service-command
zen service command
Diffstat (limited to 'src/zencore/process.cpp')
-rw-r--r--src/zencore/process.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/zencore/process.cpp b/src/zencore/process.cpp
index fcbe657cb..0b25d14f4 100644
--- a/src/zencore/process.cpp
+++ b/src/zencore/process.cpp
@@ -24,7 +24,6 @@
# include <sys/sem.h>
# include <sys/stat.h>
# include <sys/syscall.h>
-# include <sys/sysctl.h>
# include <sys/wait.h>
# include <time.h>
# include <unistd.h>
@@ -32,6 +31,8 @@
#if ZEN_PLATFORM_MAC
# include <libproc.h>
+# include <sys/types.h>
+# include <sys/sysctl.h>
#endif
ZEN_THIRD_PARTY_INCLUDES_START
@@ -41,7 +42,9 @@ ZEN_THIRD_PARTY_INCLUDES_END
namespace zen {
#if ZEN_PLATFORM_LINUX
-const bool bNoZombieChildren = []() {
+void
+IgnoreChildSignals()
+{
// When a child process exits it is put into a zombie state until the parent
// collects its result. This doesn't fit the Windows-like model that Zen uses
// where there is a less strict familial model and no zombification. Ignoring
@@ -52,8 +55,7 @@ const bool bNoZombieChildren = []() {
sigemptyset(&Action.sa_mask);
Action.sa_handler = SIG_IGN;
sigaction(SIGCHLD, &Action, nullptr);
- return true;
-}();
+}
static char
GetPidStatus(int Pid, std::error_code& OutEc)
@@ -443,6 +445,10 @@ CreateProcNormal(const std::filesystem::path& Executable, std::string_view Comma
{
CreationFlags |= CREATE_NEW_CONSOLE;
}
+ if (Options.Flags & CreateProcOptions::Flag_NoConsole)
+ {
+ CreationFlags |= CREATE_NO_WINDOW;
+ }
const wchar_t* WorkingDir = nullptr;
if (Options.WorkingDirectory != nullptr)
@@ -588,6 +594,10 @@ CreateProcUnelevated(const std::filesystem::path& Executable, std::string_view C
{
CreateProcFlags |= CREATE_NEW_CONSOLE;
}
+ if (Options.Flags & CreateProcOptions::Flag_NoConsole)
+ {
+ CreateProcFlags |= CREATE_NO_WINDOW;
+ }
ExtendableWideStringBuilder<256> CommandLineZ;
CommandLineZ << CommandLine;
@@ -798,6 +808,11 @@ IsProcessRunning(int pid, std::error_code& OutEc)
{
return false;
}
+ if (Error == ERROR_ACCESS_DENIED)
+ {
+ // Process is running under other user probably, assume it is running
+ return true;
+ }
OutEc = MakeErrorCode(Error);
return false;
}
@@ -840,6 +855,10 @@ IsProcessRunning(int pid, std::error_code& OutEc)
{
return false;
}
+ else if (Error == EPERM)
+ {
+ return true; // Running under a user we don't have access to, assume it is live
+ }
else
{
OutEc = MakeErrorCode(Error);