mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 12:55:58 +01:00
Close stdout/stderr for Xwayland
Depending on the log verbosity, close the stdout/stderr streams.
This commit is contained in:
parent
e44ab5d584
commit
93382dc445
1 changed files with 19 additions and 3 deletions
|
@ -74,6 +74,7 @@ static int fill_arg(char ***argv, const char *fmt, ...) {
|
|||
return len;
|
||||
}
|
||||
|
||||
_Noreturn
|
||||
static void exec_xwayland(struct wlr_xwayland *wlr_xwayland) {
|
||||
if (unset_cloexec(wlr_xwayland->x_fd[0]) ||
|
||||
unset_cloexec(wlr_xwayland->x_fd[1]) ||
|
||||
|
@ -123,9 +124,26 @@ static void exec_xwayland(struct wlr_xwayland *wlr_xwayland) {
|
|||
wlr_xwayland->wl_fd[1], wlr_xwayland->display, wlr_xwayland->x_fd[0],
|
||||
wlr_xwayland->x_fd[1], wlr_xwayland->wm_fd[1]);
|
||||
|
||||
// TODO: close stdout/err depending on log level
|
||||
// Closes stdout/stderr depending on log verbosity
|
||||
enum wlr_log_importance verbosity = wlr_log_get_verbosity();
|
||||
int devnull = open("/dev/null", O_WRONLY | O_CREAT, 0666);
|
||||
if (devnull < 0) {
|
||||
wlr_log_errno(WLR_ERROR, "XWayland: failed to open /dev/null");
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
if (verbosity < WLR_INFO) {
|
||||
dup2(devnull, STDOUT_FILENO);
|
||||
}
|
||||
if (verbosity < WLR_ERROR) {
|
||||
dup2(devnull, STDERR_FILENO);
|
||||
}
|
||||
|
||||
// This returns if and only if the call fails
|
||||
execvp("Xwayland", argv);
|
||||
|
||||
wlr_log_errno(WLR_ERROR, "failed to exec Xwayland");
|
||||
close(devnull);
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static void xwayland_finish_server(struct wlr_xwayland *wlr_xwayland) {
|
||||
|
@ -346,8 +364,6 @@ static bool xwayland_start_server(struct wlr_xwayland *wlr_xwayland) {
|
|||
sigprocmask(SIG_BLOCK, &sigset, NULL);
|
||||
if ((pid = fork()) == 0) {
|
||||
exec_xwayland(wlr_xwayland);
|
||||
wlr_log_errno(WLR_ERROR, "failed to exec Xwayland");
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
if (pid < 0) {
|
||||
wlr_log_errno(WLR_ERROR, "second fork failed");
|
||||
|
|
Loading…
Reference in a new issue