From 9d62d087e08a5600e7b4a6afc553e9ffe284f042 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 3 Aug 2017 21:55:09 +0530 Subject: [PATCH] Redirect xsel std streams to /dev/null Prevents hanging if the streams are blocked. Fixes #102 --- kitty/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kitty/utils.py b/kitty/utils.py index 10408f009..ea70317a2 100644 --- a/kitty/utils.py +++ b/kitty/utils.py @@ -181,7 +181,7 @@ def get_primary_selection(): return '' # There is no primary selection on OS X # glfw has no way to get the primary selection # https://github.com/glfw/glfw/issues/894 - return subprocess.check_output(['xsel', '-p']).decode('utf-8') + return subprocess.check_output(['xsel', '-p'], stderr=open(os.devnull, 'wb'), stdin=open(os.devnull, 'rb')).decode('utf-8') def base64_encode( @@ -203,7 +203,7 @@ def set_primary_selection(text): return # There is no primary selection on OS X if isinstance(text, str): text = text.encode('utf-8') - p = subprocess.Popen(['xsel', '-i', '-p'], stdin=subprocess.PIPE) + p = subprocess.Popen(['xsel', '-i', '-p'], stdin=subprocess.PIPE, stdout=open(os.devnull, 'wb'), stderr=subprocess.STDOUT) p.stdin.write(text), p.stdin.close() p.wait()