[Pkg-privacy-commits] [libgsecuredelete] 42/168: Properly read subprocess' error output on failure.
Ulrike Uhlig
u-guest at moszumanska.debian.org
Thu Jul 7 20:06:36 UTC 2016
This is an automated email from the git hooks/post-receive script.
u-guest pushed a commit to branch master
in repository libgsecuredelete.
commit 217a8f5238503f5d06c4637ed64065018ebba965
Author: Colomban Wendling <ban at herbesfolles.org>
Date: Sat Nov 14 01:01:25 2009 +0100
Properly read subprocess' error output on failure.
---
gsecuredelete/async-operation.vala | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/gsecuredelete/async-operation.vala b/gsecuredelete/async-operation.vala
index 8a9d6be..5f3b5d5 100644
--- a/gsecuredelete/async-operation.vala
+++ b/gsecuredelete/async-operation.vala
@@ -217,6 +217,23 @@ namespace Gsd
}
}
+ /* gets the standard error of the subprocess
+ * this function never fails. if the error output cannot be read, return
+ * "???" and send a warning.
+ * don't call this function before the subprocess termination as it blocks
+ * until subprocess error output's EOF */
+ private string? get_subprocess_error_msg ()
+ {
+ /* don't worry about blocking as we call this after the subprocess
+ * termination, then the fd have proper EOF */
+ try {
+ return FD.read_string (this.fd_err);
+ } catch (FDError e) {
+ warning ("Subprocess error output read failed: %s", e.message);
+ return "???";
+ }
+ }
+
/* checks if the child finished, and dispatches related things.
*
* It is meant to be called as a timeout function.
@@ -244,12 +261,11 @@ namespace Gsd
this.update_progress ();
finished = false;
} else {
- /* FIXME: the error output read may not block if empty? */
if (! Process.if_exited (exit_status)) {
- message = "Subprocess crashed: " + FD.read_string (this.fd_err);
+ message = "Subprocess crashed: " + get_subprocess_error_msg ();
} else if (Process.exit_status (exit_status) != 0) {
/* get errors reported by the child */
- message = "Subprocess failed: " + FD.read_string (this.fd_err);
+ message = "Subprocess failed: " + get_subprocess_error_msg ();
} else {
success = true;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/libgsecuredelete.git
More information about the Pkg-privacy-commits
mailing list