summaryrefslogtreecommitdiff
path: root/src/emacs.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2011-03-20 14:03:44 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2011-03-20 14:03:44 -0700
commit76f6024de6fe35fa5ff1f83439d724bbfe28b902 (patch)
tree2ccdf4dfc24fc83947262609be3bc6dadb7b92b7 /src/emacs.c
parent209394a50130f74a92d5cf2ecd9375088fd21136 (diff)
downloademacs-76f6024de6fe35fa5ff1f83439d724bbfe28b902.tar.gz
* emacs.c (Fdaemon_initialized): Do not ignore I/O errors.
Diffstat (limited to 'src/emacs.c')
-rw-r--r--src/emacs.c17
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;
}