Skip to content

Commit

Permalink
core: add an option to accept or discard command output
Browse files Browse the repository at this point in the history
fixes #1973.
  • Loading branch information
lilydjwg committed Nov 1, 2023
1 parent 481e2d2 commit 5eedded
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 4 additions & 0 deletions metadata/workarounds.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
<option name="enable_so_unloading" type="bool">
<_short>Enable calling dlclose() when a plugin is unloaded. Note that this may not work well with all plugins.</_short>
<default>false</default>
</option>
<option name="discard_command_output" type="bool">
<_short>Discard output from commands invoked by Wayfire, so that they don't end up in the logs.</_short>
<default>true</default>
</option>
</plugin>
</wayfire>
3 changes: 3 additions & 0 deletions src/core/core-impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool> discard_command_output;
};

compositor_core_impl_t& get_core_impl();
Expand Down
13 changes: 9 additions & 4 deletions src/core/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5eedded

Please sign in to comment.