[2/2] Stop redirecting stderr with proc_open

Message ID 20200727124403.GA462333@tsubame.mg0.fr
State New
Headers show
Series
  • [1/2] aurweb.spawn: Support stdout redirections to non-tty
Related show

Commit Message

Frédéric Mangano-Tarumi July 27, 2020, 12:44 p.m. UTC
Error outputs were piped to a temporary buffer that wasn’t read by
anyone, making debugging hard because errors were completely silenced.
By not explicitly redirecting stderr on proc_open, the subprocess
inherits its parent stderr.
---
 web/lib/acctfuncs.inc.php    | 2 --
 web/lib/pkgbasefuncs.inc.php | 2 --
 2 files changed, 4 deletions(-)

Comments

Lukas Fleischer July 27, 2020, 9:39 p.m. UTC | #1
On Mon, 27 Jul 2020 at 08:44:03, Frédéric Mangano-Tarumi wrote:
> Error outputs were piped to a temporary buffer that wasn\u2019t read by
> anyone, making debugging hard because errors were completely silenced.
> By not explicitly redirecting stderr on proc_open, the subprocess
> inherits its parent stderr.
> ---
>  web/lib/acctfuncs.inc.php    | 2 --
>  web/lib/pkgbasefuncs.inc.php | 2 --
>  2 files changed, 4 deletions(-)

Good point. Merged, thanks!

Patch

diff --git a/web/lib/acctfuncs.inc.php b/web/lib/acctfuncs.inc.php
index d238c0e0..ebabb840 100644
--- a/web/lib/acctfuncs.inc.php
+++ b/web/lib/acctfuncs.inc.php
@@ -1349,7 +1349,6 @@  function notify($params) {
 	$descspec = array(
 		0 => array('pipe', 'r'),
 		1 => array('pipe', 'w'),
-		2 => array('pipe', 'w')
 	);
 
 	$p = proc_open($cmd, $descspec, $pipes);
@@ -1360,7 +1359,6 @@  function notify($params) {
 
 	fclose($pipes[0]);
 	fclose($pipes[1]);
-	fclose($pipes[2]);
 
 	return proc_close($p);
 }
diff --git a/web/lib/pkgbasefuncs.inc.php b/web/lib/pkgbasefuncs.inc.php
index a4925891..22b882b4 100644
--- a/web/lib/pkgbasefuncs.inc.php
+++ b/web/lib/pkgbasefuncs.inc.php
@@ -96,7 +96,6 @@  function render_comment($id) {
 	$descspec = array(
 		0 => array('pipe', 'r'),
 		1 => array('pipe', 'w'),
-		2 => array('pipe', 'w')
 	);
 
 	$p = proc_open($cmd, $descspec, $pipes);
@@ -107,7 +106,6 @@  function render_comment($id) {
 
 	fclose($pipes[0]);
 	fclose($pipes[1]);
-	fclose($pipes[2]);
 
 	return proc_close($p);
 }