From 080c73d1a49fbde0d582ba445654b7069dce4f7c Mon Sep 17 00:00:00 2001 From: Orestis Floros Date: Sat, 29 Oct 2022 08:20:09 +0200 Subject: [PATCH] i3-dmenu-desktop: ignore SIGPIPE when writing to dmenu (#5228) Fixes broken test --- i3-dmenu-desktop | 5 +++++ testcases/t/318-i3-dmenu-desktop.t | 6 ++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/i3-dmenu-desktop b/i3-dmenu-desktop index bb693350..6e26786d 100755 --- a/i3-dmenu-desktop +++ b/i3-dmenu-desktop @@ -366,9 +366,14 @@ binmode $dmenu_in, ':utf8'; binmode $dmenu_out, ':utf8'; # Feed dmenu the possible choices. +# Since the process might have already exited, we ignore SIGPIPE. +$SIG{PIPE} = 'IGNORE'; + say $dmenu_in $_ for sort keys %choices; close($dmenu_in); +$SIG{PIPE} = 'DEFAULT'; + waitpid($pid, 0); my $status = ($? >> 8); diff --git a/testcases/t/318-i3-dmenu-desktop.t b/testcases/t/318-i3-dmenu-desktop.t index 6fd78d48..2ad7f41b 100644 --- a/testcases/t/318-i3-dmenu-desktop.t +++ b/testcases/t/318-i3-dmenu-desktop.t @@ -67,10 +67,8 @@ EOT # complete-run.pl arranges for $PATH to be set up such that the # i3-dmenu-desktop version we execute is the one from the build directory. - my $exit = system("i3-dmenu-desktop --dmenu 'echo i3-testsuite-$testcnt' &"); - if ($exit != 0) { - die "failed to run i3-dmenu-desktop"; - } + my $exit = system("(i3-dmenu-desktop --dmenu 'echo i3-testsuite-$testcnt' || echo failed with \$? > $tmpdir/fifo) &"); + die "failed to start i3-dmenu-desktop" unless $exit == 0; chomp($want_arg); # trim trailing newline my $got_args = decode_json(slurp("$tmpdir/fifo"));