diff options
| author | Teddy Wing | 2017-12-16 22:09:09 +0100 |
|---|---|---|
| committer | Teddy Wing | 2017-12-16 22:10:46 +0100 |
| commit | aa1e8f7c383c3ff9e6add8f37a1055de2f5b039e (patch) | |
| tree | c1a697b442c8ab56489d6f2f721eb590dfa612e4 /vimput.pl | |
| parent | e233ebd9b85217ed4661519fef2c258bd1b387ca (diff) | |
| download | irssi-vimput-aa1e8f7c383c3ff9e6add8f37a1055de2f5b039e.tar.bz2 | |
Only permit a single child fork
Things get really messed up if we fork multiple times. Try pressing C-x,
then switching back to the Irssi window and pressing C-x again. Another
Vim opens and the pipes get all confused. Prevent that craziness by only
ever allowing a single child fork.
Following the pattern from:
https://github.com/shabble/irssi-scripts/blob/master/feature-tests/pipes.pl
https://github.com/irssi/scripts.irssi.org/blob/d62bb05a34ffd6d8d0f719c551d8e454880ef8e1/scripts/chansearch.pl
Diffstat (limited to 'vimput.pl')
| -rw-r--r-- | vimput.pl | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -18,6 +18,8 @@ our %IRSSI = { use constant CTRL_X => 24; +my $forked = 0; + # The location of the temporary file where prompt contents are written. sub vimput_file { @@ -53,6 +55,8 @@ sub open_tmux_split { sub update_input_line_when_finished { + return if $forked; + my ($read_handle, $write_handle); pipe($read_handle, $write_handle); @@ -66,6 +70,8 @@ sub update_input_line_when_finished { return; } + $forked = 1; + if (is_child_fork($pid)) { my $fifo_path = tmpnam(); @@ -112,7 +118,7 @@ sub pipe_input { Irssi::gui_input_set($input); - # TODO: Add $forked to not spawn more than one children unnecessarily + $forked = 0; close $read_handle; Irssi::input_remove($$pipe_tag); |
