From c80fc47e280a500ff8d6c3fde53e7554272e749b Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 24 Jan 2021 04:46:49 -0700 Subject: ipc: get rid of wq_set_recv_modes Just open every FD as read/write. Perl (or any non-broken runtime) won't care and won't attempt to use F_SETFL to alter file description flags; as attempting to change those would lead to unpleasant side effects if the file description is shared with another process. --- script/lei | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'script') diff --git a/script/lei b/script/lei index 8c40bf12..006c1180 100755 --- a/script/lei +++ b/script/lei @@ -23,20 +23,19 @@ sub sigchld { sub exec_cmd { my ($fds, $argc, @argv) = @_; - my @m = (*STDIN{IO}, '<&=', *STDOUT{IO}, '>&=', *STDERR{IO}, '>&='); + my @old = (*STDIN{IO}, *STDOUT{IO}, *STDERR{IO}); my @rdr; for my $fd (@$fds) { - my ($old_io, $mode) = splice(@m, 0, 2); - open(my $tmpfh, $mode, $fd) or die "open $mode$fd: $!"; - push @rdr, $old_io, $mode, $tmpfh; + open(my $tmpfh, '+<&=', $fd) or die "open +<&=$fd: $!"; + push @rdr, shift(@old), $tmpfh; } require POSIX; # WNOHANG $SIG{CHLD} = \&sigchld; my $pid = fork // die "fork: $!"; if ($pid == 0) { my %env = map { split(/=/, $_, 2) } splice(@argv, $argc); - while (my ($old_io, $mode, $tmpfh) = splice(@rdr, 0, 3)) { - open $old_io, $mode, $tmpfh or die "open $mode: $!"; + while (my ($old_io, $tmpfh) = splice(@rdr, 0, 2)) { + open $old_io, '+<&', $tmpfh or die "open +<&=: $!"; } %ENV = (%ENV, %env); exec(@argv); -- cgit v1.2.3-24-ge0c7