diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2011-03-22 18:01:59 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2011-03-22 18:01:59 -0700 |
commit | c9c49752e15c105ded153e9ab0a42743f57184e5 (patch) | |
tree | e395db95d87459082bace9fcf3a2cec0ea3d1aea /src/emacs.c | |
parent | 9d0da923ebd2b78abb6e02f0b90cfe9d818eb301 (diff) | |
parent | b9b4b7cb4c27f9f6ad644168f0e1241e5c0d6eaa (diff) | |
download | emacs-c9c49752e15c105ded153e9ab0a42743f57184e5.tar.gz emacs-c9c49752e15c105ded153e9ab0a42743f57184e5.tar.bz2 emacs-c9c49752e15c105ded153e9ab0a42743f57184e5.zip |
Fix more problems found by GCC 4.5.2's static checks.
Diffstat (limited to 'src/emacs.c')
-rw-r--r-- | src/emacs.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/emacs.c b/src/emacs.c index 052f22ea622..bc7c07a9326 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -2312,6 +2312,7 @@ from the parent process and its tty file descriptors. */) (void) { int nfd; + int err = 0; if (!IS_DAEMON) error ("This function can only be called if emacs is run as a daemon"); @@ -2324,10 +2325,11 @@ from the parent process and its tty file descriptors. */) /* Get rid of stdin, stdout and stderr. */ nfd = open ("/dev/null", O_RDWR); - dup2 (nfd, 0); - dup2 (nfd, 1); - dup2 (nfd, 2); - close (nfd); + err |= nfd < 0; + err |= dup2 (nfd, 0) < 0; + err |= dup2 (nfd, 1) < 0; + err |= dup2 (nfd, 2) < 0; + err |= close (nfd) != 0; /* Closing the pipe will notify the parent that it can exit. FIXME: In case some other process inherited the pipe, closing it here @@ -2336,10 +2338,13 @@ from the parent process and its tty file descriptors. */) Instead, we should probably close the pipe in start-process and call-process to make sure the pipe is never inherited by subprocesses. */ - write (daemon_pipe[1], "\n", 1); - close (daemon_pipe[1]); + err |= write (daemon_pipe[1], "\n", 1) < 0; + err |= close (daemon_pipe[1]) != 0; /* Set it to an invalid value so we know we've already run this function. */ daemon_pipe[1] = -1; + + if (err) + error ("I/O error during daemon initialization"); return Qt; } |