mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-08 12:40:49 -08:00
* emacs.c (Fdaemon_initialized): Do not ignore I/O errors.
This commit is contained in:
parent
c184bbfdfd
commit
dc1ca6a87f
2 changed files with 13 additions and 6 deletions
|
|
@ -1,5 +1,7 @@
|
|||
2011-03-20 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* emacs.c (Fdaemon_initialized): Do not ignore I/O errors.
|
||||
|
||||
* process.c (Fmake_network_process): Use socklen_t, not int,
|
||||
where POSIX says socklen_t is required in portable programs.
|
||||
This fixes a porting bug on hosts like 64-bit HP-UX, where
|
||||
|
|
|
|||
17
src/emacs.c
17
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue