Skip to content

Commit

Permalink
main: ignore SIGPIPE globally. (WayfireWM#2096)
Browse files Browse the repository at this point in the history
By default, writing to a pipe that has been closed terminates the
program with SIGPIPE. Ignoring SIGPIPE results in the syscall
failing with EPIPE instead.

This generally prevents crashing on IPCs. One crash I found is in
write_selection_property_to_wl_client when using xpra to run
remote apps. If xpra updates the selection too often, wayfire
crashes with SIGPIPE. But this probably prevents other crashes in
general. It also matches what other compositors do, e.g., sway
also globally ignores SIGPIPE to prevent crashes caused by IPCs.
  • Loading branch information
lcolitti authored and lilydjwg committed Jan 21, 2024
1 parent b068f35 commit 6aa1835
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ int main(int argc, char *argv[])
}
}

/* Don't crash on SIGPIPE, e.g., when doing IPC to a client whose fd has been closed. */
signal(SIGPIPE, SIG_IGN);

wf::log::initialize_logging(std::cout, log_level, detect_color_mode());

parse_extended_debugging(extended_debug_categories);
Expand Down

0 comments on commit 6aa1835

Please sign in to comment.