aboutsummaryrefslogtreecommitdiffstats
path: root/vimput.pl
diff options
context:
space:
mode:
authorTeddy Wing2017-12-16 21:00:47 +0100
committerTeddy Wing2017-12-16 21:00:47 +0100
commitefec182afe6e2b3dc8980c1740d22f53ccdb0109 (patch)
tree04bb6615fd51f63468bd2bb04c35b0669774505e /vimput.pl
parent7c41d62cf755666df87ad88f82adfcb939730a4f (diff)
downloadirssi-vimput-efec182afe6e2b3dc8980c1740d22f53ccdb0109.tar.bz2
Use two pipe to communicate between forks
Instead of passing messages (prompt input) and commands (location of temp file) on the same pipe from the child fork to the parent, use separate pipes. This eliminates blocking behaviour and prints the temp file location right away. It is then able to read from the socket, and feed the text up the pipes to be printed too. Stupid error on my part feeding `@args` to the second `Irssi::input_add` instead of `@ar2`. Yay, it works! Suck it Perl!
Diffstat (limited to 'vimput.pl')
-rw-r--r--vimput.pl27
1 files changed, 14 insertions, 13 deletions
diff --git a/vimput.pl b/vimput.pl
index e7a1487..d1a85d1 100644
--- a/vimput.pl
+++ b/vimput.pl
@@ -146,7 +146,7 @@ sub update_input_line_when_finished {
my ($read_handle, $write_handle, $command_handle, $fuckface);
pipe($read_handle, $write_handle);
- # pipe($fuckface, $command_handle);
+ pipe($fuckface, $command_handle);
# pipe($read_handle, $command_handle);
# $write_handle->autoflush(1);
@@ -159,7 +159,7 @@ sub update_input_line_when_finished {
close $read_handle;
close $write_handle;
close $command_handle;
- # close $fuckface;
+ close $fuckface;
return;
}
@@ -184,9 +184,9 @@ if ($pid == 0) {
# my $tempdir = tempdir('vimput.XXXXXXXXXX', TMPDIR => 1, CLEANUP => 1);
# my $fifo_path = "$tempdir/fifo";
- print $write_handle VIMPUT_IPC_COMMAND_PREFIX . $fifo_path;
- # print $command_handle VIMPUT_IPC_COMMAND_PREFIX . $fifo_path;
- # close $command_handle;
+ # print $write_handle VIMPUT_IPC_COMMAND_PREFIX . $fifo_path;
+ print $command_handle VIMPUT_IPC_COMMAND_PREFIX . $fifo_path;
+ close $command_handle;
# mkfifo($fifo_path, 0600) or die $!;
#
@@ -225,6 +225,7 @@ if ($pid == 0) {
}
else {
close $write_handle;
+ close $command_handle;
Irssi::pidwait_add($pid);
@@ -236,14 +237,14 @@ else {
\&pipe_input,
\@args,
);
- # my $p2;
- # my @ar2 = ($fuckface, \$p2);
- # $p2 = Irssi::input_add(
- # fileno $fuckface,
- # Irssi::INPUT_READ,
- # \&pipe_input,
- # \@args
- # );
+ my $p2;
+ my @ar2 = ($fuckface, \$p2);
+ $p2 = Irssi::input_add(
+ fileno $fuckface,
+ Irssi::INPUT_READ,
+ \&pipe_input,
+ \@ar2,
+ );
}
}