diff options
| author | Teddy Wing | 2017-12-16 21:07:36 +0100 |
|---|---|---|
| committer | Teddy Wing | 2017-12-16 21:07:36 +0100 |
| commit | 22203ce9b5b95d37d2221e67e9e1d045f7830740 (patch) | |
| tree | f2347bd8ef2406248cbd643ffbca12865e1e71b3 | |
| parent | 01fe804561f1b8ce4e4da9763c857ef7302c2ee5 (diff) | |
| download | irssi-vimput-22203ce9b5b95d37d2221e67e9e1d045f7830740.tar.bz2 | |
Put the FIFO back in
Now that we have two pipes to communicate between our forks, test the
FIFO again instead of the socket.
The reason why I tried using a socket instead was because I was hoping
that would get rid of the pipe blocking, but it didn't. Instead it
exhibited the same blocking behaviour as the pipe.
Re-enable the FIFO instead of the socket. I'm going to go with this
version instead because it seems like a pipe is more light-weight and it
works basically the same.
| -rw-r--r-- | vimput.pl | 50 |
1 files changed, 25 insertions, 25 deletions
@@ -188,35 +188,35 @@ if ($pid == 0) { print $command_handle VIMPUT_IPC_COMMAND_PREFIX . $fifo_path; close $command_handle; - # mkfifo($fifo_path, 0600) or die $!; - # - # open my $fifo, '<', $fifo_path or die $!; - # $fifo->autoflush(1); - # - # while (<$fifo>) { - # print $write_handle $_; - # } - # - # close $fifo; - - my $socket_path = $fifo_path; + mkfifo($fifo_path, 0600) or die $!; - my $socket = IO::Socket::UNIX->new( - Local => $socket_path, - Type => SOCK_STREAM, - Listen => 1, - ) or die "Failed to create socket: $!"; + open my $fifo, '<', $fifo_path or die $!; + $fifo->autoflush(1); - # $socket->blocking(0); - - my $connection = $socket->accept(); - $connection->autoflush(1); - - while (my $line = <$connection>) { - print $write_handle $line; + while (<$fifo>) { + print $write_handle $_; } - close $socket; + close $fifo; + + # my $socket_path = $fifo_path; + # + # my $socket = IO::Socket::UNIX->new( + # Local => $socket_path, + # Type => SOCK_STREAM, + # Listen => 1, + # ) or die "Failed to create socket: $!"; + # + # # $socket->blocking(0); + # + # my $connection = $socket->accept(); + # $connection->autoflush(1); + # + # while (my $line = <$connection>) { + # print $write_handle $line; + # } + # + # close $socket; close $write_handle; |
