From 84ff19af19f6ca44c658bf4fb0f3e9d0214ae8f0 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 16 Dec 2017 21:38:21 +0100 Subject: Open Vim instance without blocking I tried to open the Vim instance in `pipe_open_tmux_split`, but this gave me the same problems as before with Vim not able to write to the pipe. This was because the main Irssi process was blocked on the `open` and wasn't reading from the pipe. The mistake was opening Vim from the parent Irssi. Instead, open it from the child fork so we don't block the parent and all is good. We can open Vim and correctly save to the pipe. Yeah! --- vimput.pl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'vimput.pl') diff --git a/vimput.pl b/vimput.pl index fc9d38e..ad6dea3 100644 --- a/vimput.pl +++ b/vimput.pl @@ -185,9 +185,11 @@ if ($pid == 0) { # my $fifo_path = "$tempdir/fifo"; # print $write_handle VIMPUT_IPC_COMMAND_PREFIX . $fifo_path; - print $command_handle VIMPUT_IPC_COMMAND_PREFIX . $fifo_path; + # print $command_handle $fifo_path; close $command_handle; + open_tmux_split('rando', $fifo_path); + mkfifo($fifo_path, 0600) or die $!; open my $fifo, '<', $fifo_path or die $!; @@ -267,9 +269,9 @@ sub pipe_open_tmux_split { my ($args) = @_; my ($read_handle, $pipe_tag) = @$args; - my $input = <$read_handle>; + my $fifo_path = <$read_handle>; - print 'C: ' . $input; + # open_tmux_split('rando', $fifo_path); # TODO: Add $forked to not spawn more than one children unnecessarily -- cgit v1.2.3