diff options
| author | Stefan Boberg <[email protected]> | 2026-04-13 14:05:03 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2026-04-13 14:05:03 +0200 |
| commit | c49e5b15e0f86080d7d33e4e31aecfb701f8f96f (patch) | |
| tree | ff41dcec20502c0cc4cf853222273f50d025cda3 /src/zencore/process.cpp | |
| parent | Add MemoryCidStore and ChunkStore interface (#940) (diff) | |
| download | zen-c49e5b15e0f86080d7d33e4e31aecfb701f8f96f.tar.xz zen-c49e5b15e0f86080d7d33e4e31aecfb701f8f96f.zip | |
Some minor polish from tourist branch (#949)
- Replace per-type fmt::formatter specializations (StringBuilderBase, NiceBase) with a single generic formatter using a HasStringViewConversion concept
- Add ThousandsNum for comma-separated integer formatting (e.g. "1,234,567")
- Thread naming now accepts a sort hint for trace ordering
- Fix main thread trace registration to use actual thread ID and sort first
- Add ExpandEnvironmentVariables() for expanding %VAR% references in strings, with tests
- Add ParseHexBytes() overload with expected byte count validation
- Add Flag_BelowNormalPriority to CreateProcOptions (BELOW_NORMAL_PRIORITY_CLASS on Windows, setpriority on POSIX)
- Add PrettyScroll progress bar mode that pins the status line to the bottom of the terminal using scroll regions, with signal handler cleanup for Ctrl+C/SIGTERM
Diffstat (limited to 'src/zencore/process.cpp')
| -rw-r--r-- | src/zencore/process.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/zencore/process.cpp b/src/zencore/process.cpp index ee821944a..aa41c82ff 100644 --- a/src/zencore/process.cpp +++ b/src/zencore/process.cpp @@ -28,6 +28,7 @@ ZEN_THIRD_PARTY_INCLUDES_START # include <pthread.h> # include <signal.h> # include <sys/file.h> +# include <sys/resource.h> # include <sys/sem.h> # include <sys/stat.h> # include <sys/syscall.h> @@ -833,6 +834,10 @@ CreateProcNormal(const std::filesystem::path& Executable, std::string_view Comma { CreationFlags |= CREATE_NEW_PROCESS_GROUP; } + if (Options.Flags & CreateProcOptions::Flag_BelowNormalPriority) + { + CreationFlags |= BELOW_NORMAL_PRIORITY_CLASS; + } if (AssignToJob) { CreationFlags |= CREATE_SUSPENDED; @@ -1043,6 +1048,10 @@ CreateProcUnelevated(const std::filesystem::path& Executable, std::string_view C { CreateProcFlags |= CREATE_NO_WINDOW; } + if (Options.Flags & CreateProcOptions::Flag_BelowNormalPriority) + { + CreateProcFlags |= BELOW_NORMAL_PRIORITY_CLASS; + } if (AssignToJob) { CreateProcFlags |= CREATE_SUSPENDED; @@ -1201,6 +1210,11 @@ CreateProc(const std::filesystem::path& Executable, std::string_view CommandLine _exit(127); } + if (Options.Flags & CreateProcOptions::Flag_BelowNormalPriority) + { + setpriority(PRIO_PROCESS, ChildPid, 5); + } + return ChildPid; #else // macOS std::vector<char*> ArgV; @@ -1280,6 +1294,11 @@ CreateProc(const std::filesystem::path& Executable, std::string_view CommandLine ThrowSystemError(Err, "Failed to posix_spawn a new child process"); } + if (Options.Flags & CreateProcOptions::Flag_BelowNormalPriority) + { + setpriority(PRIO_PROCESS, ChildPid, 5); + } + return int(ChildPid); #endif } |