summaryrefslogtreecommitdiffstats
path: root/bin/tmux-clipboard
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2018-05-20 01:57:02 -0400
committerJesse Luehrs <doy@tozt.net>2018-05-20 01:58:10 -0400
commit495624c0783a6eadd94ff9d841234d6a7e21d0c0 (patch)
tree194e3fdddbbcd77fcda65b7f66ecc86aa23d1e0d /bin/tmux-clipboard
parent0b411664142284360b00a1c302ed871324601f57 (diff)
downloadconf-495624c0783a6eadd94ff9d841234d6a7e21d0c0.tar.gz
conf-495624c0783a6eadd94ff9d841234d6a7e21d0c0.zip
close stdin/stdout/stderr after forking
tmux hangs while the xclip process still exists otherwise (and the xclip process has to stick around after copying in order to provide the data to subsequent paste requests)
Diffstat (limited to 'bin/tmux-clipboard')
-rwxr-xr-xbin/tmux-clipboard9
1 files changed, 8 insertions, 1 deletions
diff --git a/bin/tmux-clipboard b/bin/tmux-clipboard
index 455fa1a..1e10fcf 100755
--- a/bin/tmux-clipboard
+++ b/bin/tmux-clipboard
@@ -21,6 +21,10 @@ mkfifo("$fifo_file", 0700);
if ($ARGV[0] eq 'copy') {
if (fork) {
+ close STDIN;
+ close STDOUT;
+ close STDERR;
+
open my $clipboard, '|-', COPY_CMD
or die "can't copy from clipboard using ${\COPY_CMD}: $!";
$clipboard->print($fifo_file->slurp);
@@ -32,6 +36,10 @@ if ($ARGV[0] eq 'copy') {
}
elsif ($ARGV[0] eq 'paste') {
if (fork) {
+ close STDIN;
+ close STDOUT;
+ close STDERR;
+
open my $clipboard, '-|', PASTE_CMD
or die "can't paste from clipboard using ${\PASTE_CMD}: $!";
my $contents = do { local $/; <$clipboard> };
@@ -46,4 +54,3 @@ elsif ($ARGV[0] eq 'paste') {
else {
die "usage: $0 [copy|paste]";
}
-