* bug#8303: Emacs daemon initialization should not ignore I/O errors
@ 2011-03-20 23:34 Paul Eggert
0 siblings, 0 replies; only message in thread
From: Paul Eggert @ 2011-03-20 23:34 UTC (permalink / raw)
To: 8303
Severity: minor
daemon-initialized currently ignores I/O errors when setting
up the daemon, but it should report them, on the off chance that
system resources are low so that (for example) one cannot open
/dev/null or dup a file descriptor. I plan to install the following
patch in the trunk, to address this.
2011-03-20 Paul Eggert <eggert@cs.ucla.edu>
* emacs.c (Fdaemon_initialized): Do not ignore I/O errors.
--- src/emacs.c 2011-03-17 16:32:03 +0000
+++ src/emacs.c 2011-03-20 21:03:44 +0000
@@ -2312,6 +2312,7 @@
(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 @@
/* 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 @@
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;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-03-20 23:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-20 23:34 bug#8303: Emacs daemon initialization should not ignore I/O errors Paul Eggert
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.