From 5eedded46ccd1e1b2daffc7cb13ca40f691e1471 Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Wed, 1 Nov 2023 20:16:54 +0800 Subject: [PATCH] core: add an option to accept or discard command output fixes #1973. --- metadata/workarounds.xml | 4 ++++ src/core/core-impl.hpp | 3 +++ src/core/core.cpp | 13 +++++++++---- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/metadata/workarounds.xml b/metadata/workarounds.xml index f71e45259..02f659930 100644 --- a/metadata/workarounds.xml +++ b/metadata/workarounds.xml @@ -49,6 +49,10 @@ + diff --git a/src/core/core-impl.hpp b/src/core/core-impl.hpp index fdeb44967..004b7e779 100644 --- a/src/core/core-impl.hpp +++ b/src/core/core-impl.hpp @@ -81,6 +81,9 @@ class compositor_core_impl_t : public compositor_core_t compositor_state_t state = compositor_state_t::UNKNOWN; compositor_core_impl_t(); virtual ~compositor_core_impl_t(); + + private: + wf::option_wrapper_t discard_command_output; }; compositor_core_impl_t& get_core_impl(); diff --git a/src/core/core.cpp b/src/core/core.cpp index b133f0109..782a17a1f 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -216,6 +216,8 @@ void wf::compositor_core_impl_t::post_init() // Start processing cursor events seat->priv->cursor->setup_listeners(); + discard_command_output.load_option("workarounds/discard_command_output"); + core_startup_finished_signal startup_ev; this->emit(&startup_ev); } @@ -391,10 +393,13 @@ pid_t wf::compositor_core_impl_t::run(std::string command) } #endif - int dev_null = open("/dev/null", O_WRONLY); - dup2(dev_null, 1); - dup2(dev_null, 2); - close(dev_null); + if (discard_command_output) + { + int dev_null = open("/dev/null", O_WRONLY); + dup2(dev_null, 1); + dup2(dev_null, 2); + close(dev_null); + } _exit(execl("/bin/sh", "/bin/sh", "-c", command.c_str(), NULL)); } else