aboutsummaryrefslogtreecommitdiff
path: root/sway.desktop
diff options
context:
space:
mode:
authorFurkan Sahin <furkan-dev@proton.me>2025-02-11 12:41:59 +0100
committerFurkan Sahin <furkan-dev@proton.me>2025-02-11 12:41:59 +0100
commitc222fc74ebf9379108bdfacb7c973aef1d1f1bd5 (patch)
treea973873fbb7a3f7dd78418fad160cbd87cc8dce9 /sway.desktop
parent05caa9a3f41bdb983108c0ddf29bacfa7eb2682d (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