diff -u xfce4-genmon-plugin-3.2.orig/panel-plugin/cmdspawn.c xfce4-genmon-plugin-3.2.new2/panel-plugin/cmdspawn.c --- xfce4-genmon-plugin-3.2.orig/panel-plugin/cmdspawn.c 2007-11-23 07:32:40.000000000 -0800 +++ xfce4-genmon-plugin-3.2.new2/panel-plugin/cmdspawn.c 2008-04-29 12:48:58.000000000 -0700 @@ -146,9 +146,8 @@ int genmon_Spawn (char *const argv[], char *const p_pcOutput, const size_t p_BufferSize, const int wait) /**********************************************************************/ - /* Spawn a command and capture its output */ - /* Return 0 on success, otherwise copy stderr into the output string and - return -1 */ + /* Spawn a command and capture its output from stdout or stderr */ + /* Return 0 on success, otherwise -1 */ { enum { OUT, ERR, OUT_ERR }; enum { RD, WR, RD_WR }; @@ -184,6 +183,7 @@ return (-1); case 0: /* Redirect stdout/stderr to associated pipe's write-ends */ + close(0); /* stdin is not used in child */ for (i = 0; i < OUT_ERR; i++) { j = i + 1; // stdout/stderr file descriptor close (j); @@ -199,6 +199,9 @@ exit (-1); } + for (i = 0; i < OUT_ERR; i++) + close (aaiPipe[i][WR]); /* close write end of pipes in parent */ + /* Wait for child completion */ if (wait == 1) { @@ -223,7 +226,7 @@ break; if (i < OUT_ERR) read (aaiPipe[i][RD], p_pcOutput, BufSafeSize); - fError = (i != OUT); + fError = (i == OUT_ERR); /* Remove trailing carriage return if any */ if (p_pcOutput[(i = strlen (p_pcOutput) - 1)] == '\n') @@ -231,10 +234,9 @@ } End: - /* Close created pipes */ + /* Close read end of pipes */ for (i = 0; i < OUT_ERR; i++) - for (j = 0; j < RD_WR; j++) - close (aaiPipe[i][j]); + close (aaiPipe[i][RD]); return (-fError); }// Spawn() @@ -244,9 +246,8 @@ int genmon_SpawnCmd (const char *const p_pcCmdLine, char *const p_pcOutput, const size_t p_BufferSize, const int wait) /**********************************************************************/ - /* Spawn a command and capture its output */ - /* Return 0 on success, otherwise copy stderr into the output string and - return -1 */ + /* Parse a command line, spawn the command, and capture its output from stdout or stderr */ + /* Return 0 on success, otherwise -1 */ { char **argv; int argc; diff -u xfce4-genmon-plugin-3.2.orig/panel-plugin/cmdspawn.h xfce4-genmon-plugin-3.2.new2/panel-plugin/cmdspawn.h --- xfce4-genmon-plugin-3.2.orig/panel-plugin/cmdspawn.h 2007-11-23 07:32:40.000000000 -0800 +++ xfce4-genmon-plugin-3.2.new2/panel-plugin/cmdspawn.h 2008-04-29 12:48:55.000000000 -0700 @@ -40,9 +40,8 @@ int genmon_SpawnCmd (const char *const cmdline, char *const StdOutCapture, const size_t StdOutSize, const int wait); - /* Spawn the given command and capture its output (stdout) */ - /* Return 0 on success, otherwise copy stderr into the output string - and return -1 */ + /* Parse a command line, spawn the command, and capture its output from stdout or stderr */ + /* Return 0 on success, otherwise -1 */ #ifdef __cplusplus }/* extern "C" */ #endif