aboutsummaryrefslogtreecommitdiff
path: root/sway.desktop
diff options
context:
space:
mode:
authorKenny Levinsen <kl@kl.wtf>2025-02-11 12:41:59 +0100
committerSimon Ser <contact@emersion.fr>2025-03-06 11:46:59 +0100
commite3d9cc2aa5f1c298fd956b64e5e20f50aaac72fe (patch)
treea973873fbb7a3f7dd78418fad160cbd87cc8dce9 /sway.desktop
parent962e1e70a60e9f39d2fdb6fa1810017682fd1f7b (diff)
Rework fork/exec strategy
cmd_exec_process is used whenever sway is meant to execute a child process on behalf of the user, and had a lot of complexity. In order to avoid having to wait on the user's process, a double-fork was used, which in turn required us to wait on the outer process. In order to track the child PID for launcher purposes, a pipe was used to transmit the PID back to sway. This resulted in sway blocking for 5-6 ms per exec on my system, which is quite significant. The error handling was also quite lacking - the read loop did not handle errors at all for example. Instead, teach sway to handle SIGCHLD and do away with the double-fork. This in turn allows us to get rid of the pipe as we can record the child's PID directly. This reduces the time we block to just 1.5 ms on my system. We'd be able to get down to just 150 µs if we could use posix_spawn(3), but posix_spawn(3) cannot reset NOFILE. clone(2) or vfork(2) would be alternatives, but that presents portability issues. This change is replicated for swaybar, swaybg and swaynag handling, which had similar albeit less complicated implementations.
Diffstat (limited to 'sway.desktop')
0 files changed, 0 insertions, 0 deletions