From: Michael Stapelberg Date: Tue, 4 Oct 2011 22:31:06 +0000 (+0100) Subject: tests: SocketActivation: only close() and dup2() if fileno(socket) != 3 X-Git-Tag: 4.1~122^2~6 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c8d42fbabed90f2d416500821b880a733e366705;p=i3%2Fi3 tests: SocketActivation: only close() and dup2() if fileno(socket) != 3 --- 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";