From 3c9f31b2f1249a2f5911a300ad48a894443d3009 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Tue, 3 Feb 2026 08:54:51 -0600 Subject: fix(video-recording): kill orphan wf-recorder on Wayland On Wayland, video recording uses a shell pipeline: wf-recorder | ffmpeg. When stopping, SIGINT only reaches ffmpeg, leaving wf-recorder running as an orphan. This blocks subsequent recordings (0-byte files or no file). Fix: - On stop: explicitly pkill wf-recorder before interrupting ffmpeg - On start: kill any orphan wf-recorder from previous crashes - Increase finalization wait from 0.2s to 0.5s for proper cleanup --- modules/video-audio-recording.el | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/video-audio-recording.el b/modules/video-audio-recording.el index e44f83c8..a0e9970b 100644 --- a/modules/video-audio-recording.el +++ b/modules/video-audio-recording.el @@ -473,6 +473,10 @@ Return t if found, nil otherwise." Uses wf-recorder on Wayland, x11grab on X11." (cj/recording-check-ffmpeg) (unless cj/video-recording-ffmpeg-process + ;; On Wayland, kill any orphan wf-recorder processes from previous crashes + (when (cj/recording--wayland-p) + (call-process "pkill" nil nil nil "-INT" "wf-recorder") + (sit-for 0.1)) (let* ((devices (cj/recording-get-devices)) (mic-device (car devices)) (system-device (cdr devices)) @@ -576,10 +580,15 @@ Use C-; r c to configure which device to use - it must match the device your pho (interactive) (if cj/video-recording-ffmpeg-process (progn + ;; On Wayland, we run wf-recorder | ffmpeg pipeline. + ;; SIGINT only reaches ffmpeg, leaving wf-recorder as orphan. + ;; Kill wf-recorder explicitly first, then ffmpeg will exit naturally. + (when (cj/recording--wayland-p) + (call-process "pkill" nil nil nil "-INT" "wf-recorder")) ;; Use interrupt-process to send SIGINT (graceful termination) (interrupt-process cj/video-recording-ffmpeg-process) ;; Give ffmpeg a moment to finalize the file - (sit-for 0.2) + (sit-for 0.5) (setq cj/video-recording-ffmpeg-process nil) (force-mode-line-update t) (message "Stopped video recording.")) -- cgit v1.2.3