diff --git a/VERSION b/VERSION index ee94dd8..b60d719 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.8.3 +0.8.4 diff --git a/include/hyprutils/os/Process.hpp b/include/hyprutils/os/Process.hpp index 477e952..6cdea4e 100644 --- a/include/hyprutils/os/Process.hpp +++ b/include/hyprutils/os/Process.hpp @@ -22,6 +22,8 @@ namespace Hyprutils { void addEnv(const std::string& name, const std::string& value); + // only for async, sync doesn't make sense + void setStdinFD(int fd); // only for async, sync doesn't make sense void setStdoutFD(int fd); // only for async, sync doesn't make sense @@ -47,4 +49,4 @@ namespace Hyprutils { impl* m_impl; }; } -} \ No newline at end of file +} diff --git a/nix/default.nix b/nix/default.nix index b7096fd..0db0819 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -8,13 +8,16 @@ version ? "git", doCheck ? false, debug ? false, + # whether to use the mold linker + # disable this for older machines without SSE4_2 and AVX2 support + withMold ? true, }: let inherit (builtins) foldl'; inherit (lib.lists) flatten; inherit (lib.strings) optionalString; adapters = flatten [ - stdenvAdapters.useMoldLinker + (lib.optional withMold stdenvAdapters.useMoldLinker) (lib.optional debug stdenvAdapters.keepDebugInfo) ]; diff --git a/src/os/Process.cpp b/src/os/Process.cpp index 3982b62..335d6b1 100644 --- a/src/os/Process.cpp +++ b/src/os/Process.cpp @@ -19,7 +19,7 @@ struct Hyprutils::OS::CProcess::impl { std::vector args; std::vector> env; pid_t grandchildPid = 0; - int stdoutFD = -1, stderrFD = -1, exitCode = 0; + int stdoutFD = -1, stderrFD = -1, exitCode = 0, stdinFD = -1; }; Hyprutils::OS::CProcess::CProcess(const std::string& binary, const std::vector& args) : m_impl(new impl()) { @@ -213,10 +213,18 @@ bool Hyprutils::OS::CProcess::runAsync() { setenv(n.c_str(), v.c_str(), 1); } - if (m_impl->stdoutFD != -1) - dup2(m_impl->stdoutFD, 1); - if (m_impl->stderrFD != -1) - dup2(m_impl->stderrFD, 2); + if (m_impl->stdinFD != -1) { + dup2(m_impl->stdinFD, STDIN_FILENO); + close(m_impl->stdinFD); + } + if (m_impl->stdoutFD != -1) { + dup2(m_impl->stdoutFD, STDOUT_FILENO); + close(m_impl->stdoutFD); + } + if (m_impl->stderrFD != -1) { + dup2(m_impl->stderrFD, STDERR_FILENO); + close(m_impl->stderrFD); + } execvp(m_impl->binary.c_str(), argsC.data()); _exit(0); @@ -264,6 +272,10 @@ int Hyprutils::OS::CProcess::exitCode() { return m_impl->exitCode; } +void Hyprutils::OS::CProcess::setStdinFD(int fd) { + m_impl->stdinFD = fd; +} + void Hyprutils::OS::CProcess::setStdoutFD(int fd) { m_impl->stdoutFD = fd; }