From c0940492ed90d71097107a66cf2b184ceaec0da6 Mon Sep 17 00:00:00 2001 From: Jon Lund Steffensen Date: Mon, 3 Nov 2014 20:57:15 -0500 Subject: redshift-gtk: Forward errors from child to stderr This requires that the stderr (and stdout) are emptied when the child process exits, otherwise redshift-gtk will exit before the error output is forwarded. Also, the '-v' parameter is moved to the beginning of the command line to avoid error output including this (e.g. `redshift-gtk -l` would complain about the missing location provided `-v`). --- src/redshift-gtk/statusicon.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/redshift-gtk/statusicon.py') diff --git a/src/redshift-gtk/statusicon.py b/src/redshift-gtk/statusicon.py index 04a944f..8bcc572 100644 --- a/src/redshift-gtk/statusicon.py +++ b/src/redshift-gtk/statusicon.py @@ -14,7 +14,7 @@ # You should have received a copy of the GNU General Public License # along with Redshift. If not, see . -# Copyright (c) 2013 Jon Lund Steffensen +# Copyright (c) 2013-2014 Jon Lund Steffensen '''GUI status icon for Redshift. @@ -58,7 +58,7 @@ class RedshiftStatusIcon(object): # Start redshift with arguments args.insert(0, os.path.join(defs.BINDIR, 'redshift')) if '-v' not in args: - args.append('-v') + args.insert(1, '-v') self.start_child_process(args) @@ -288,6 +288,15 @@ class RedshiftStatusIcon(object): os.kill(self.process[0], signal.SIGUSR1) def child_cb(self, pid, cond, data=None): + # Empty stdout and stderr + for f, dest in ((self.process[2], sys.stdout), + (self.process[3], sys.stderr)): + while True: + buf = os.read(f, 256).decode('utf-8') + if buf == '': + break + print(buf, end='', file=dest) + sys.exit(-1) def child_key_change_cb(self, key, value): @@ -320,6 +329,8 @@ class RedshiftStatusIcon(object): ib.buf = last if stdout: self.child_stdout_line_cb(first) + else: + print(first, file=sys.stderr) return True -- cgit v1.2.3-70-g09d2