From c8d42fbabed90f2d416500821b880a733e366705 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Tue, 4 Oct 2011 23:31:06 +0100 Subject: [PATCH] tests: SocketActivation: only close() and dup2() if fileno(socket) != 3 --- testcases/lib/SocketActivation.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/testcases/lib/SocketActivation.pm b/testcases/lib/SocketActivation.pm index 92e514d5..70bbec05 100644 --- a/testcases/lib/SocketActivation.pm +++ b/testcases/lib/SocketActivation.pm @@ -56,8 +56,12 @@ sub activate_i3 { $ENV{DISPLAY} = $args{display}; $^F = 3; - POSIX::close(3); - POSIX::dup2(fileno($socket), 3); + # If the socket does not use file descriptor 3 by chance already, we + # close fd 3 and dup2() the socket to 3. + if (fileno($socket) != 3) { + POSIX::close(3); + POSIX::dup2(fileno($socket), 3); + } # now execute i3 my $i3cmd = abs_path("../i3") . " -V -d all --disable-signalhandler"; -- 2.39.5