aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2017-12-16 21:38:21 +0100
committerTeddy Wing2017-12-16 21:40:44 +0100
commit84ff19af19f6ca44c658bf4fb0f3e9d0214ae8f0 (patch)
treee06fe354187a5ff19ebe724314dc7a7d5948015b
parent471af2ce8aa3e152336761b2c618f673f2c0adf8 (diff)
downloadirssi-vimput-84ff19af19f6ca44c658bf4fb0f3e9d0214ae8f0.tar.bz2
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!
-rw-r--r--vimput.pl8
1 files changed, 5 insertions, 3 deletions
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