From: Sebastian Stark Date: Wed, 22 Oct 2008 12:59:11 +0000 (+0200) Subject: open /dev/null for reading AND writing when executing rsync. X-Git-Tag: v0.1.1~4 X-Git-Url: http://git.tuebingen.mpg.de/?p=dss.git;a=commitdiff_plain;h=f9af4b1114a1a9b3b88a7d89985220ff586b5ef1 open /dev/null for reading AND writing when executing This is needed for child processes to be able to write to fd 2 without failing. For example, rsync will not be able to write an error message because of "Bad file descriptor" which in turn leads to rsync exiting with meaningless exit code 13 ("Errors with program diagnostics"), masking the actual error and exit code. The fact that rsync uses exit code 13 in that case makes this bug particularly painful since 13 is interpreted by dss as a temporary rsync error that can be "fixed" by simply restarting rsync. This can lead to an infinite loop, obviously. --- diff --git a/exec.c b/exec.c index b1f60fa..d9f5b1b 100644 --- a/exec.c +++ b/exec.c @@ -48,7 +48,7 @@ int dss_exec(pid_t *pid, const char *file, char *const *const args, int *fds) goto err_out; if (!fds[0] || !fds[1] || !fds[2]) { ret = -E_NULL_OPEN; - null = open("/dev/null", O_RDONLY); + null = open("/dev/null", O_RDWR); if (null < 0) goto err_out; }