From: Christophe CURIS <christophe.cu...@free.fr> As pointed by Coverity, the file descriptor used in 'dup' to become the child process's STDIN is leaked, because it will not be used anymore, so we close it after the dup.
Similarly, the file descriptors that represent the other ends of the pipe for each process are useless, so let's close them too to keep a reasonable number of opened file descriptors over time. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> --- src/misc.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/misc.c b/src/misc.c index 096052a..5d54561 100644 --- a/src/misc.c +++ b/src/misc.c @@ -945,6 +945,9 @@ Bool start_bg_helper(WScreen *scr) } else if (pid == 0) { char *dither; + /* We don't need this side of the pipe in the child process */ + close(filedes[1]); + SetupEnvironment(scr); if (close(0) < 0) @@ -952,6 +955,7 @@ Bool start_bg_helper(WScreen *scr) if (dup(filedes[0]) < 0) { werror("dup() failed:can't set workspace specific background image"); } + close(filedes[0]); dither = wPreferences.no_dithering ? "-m" : "-d"; if (wPreferences.smooth_workspace_back) execlp("wmsetbg", "wmsetbg", "-helper", "-S", dither, NULL); @@ -961,9 +965,9 @@ Bool start_bg_helper(WScreen *scr) exit(1); } else { - if (fcntl(filedes[0], F_SETFD, FD_CLOEXEC) < 0) { - werror("error setting close-on-exec flag"); - } + /* We don't need this side of the pipe in the parent process */ + close(filedes[0]); + if (fcntl(filedes[1], F_SETFD, FD_CLOEXEC) < 0) { werror("error setting close-on-exec flag"); } -- 2.1.1 -- To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.