diff options
| author | Paul Eggert | 2011-03-20 14:03:44 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-03-20 14:03:44 -0700 |
| commit | dc1ca6a87f1e100a054b0e5eab64da30dc5cad6f (patch) | |
| tree | 1f159caefd3a26d41a122b1b702de3be2a46c4e4 | |
| parent | c184bbfdfd547bbf61e719be92460dcebaed85a3 (diff) | |
| download | emacs-dc1ca6a87f1e100a054b0e5eab64da30dc5cad6f.tar.gz emacs-dc1ca6a87f1e100a054b0e5eab64da30dc5cad6f.zip | |
* emacs.c (Fdaemon_initialized): Do not ignore I/O errors.
| -rw-r--r-- | src/ChangeLog | 2 | ||||
| -rw-r--r-- | src/emacs.c | 17 |
2 files changed, 13 insertions, 6 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 0b2a0d44c5f..82213687708 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,7 @@ | |||
| 1 | 2011-03-20 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2011-03-20 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | * emacs.c (Fdaemon_initialized): Do not ignore I/O errors. | ||
| 4 | |||
| 3 | * process.c (Fmake_network_process): Use socklen_t, not int, | 5 | * process.c (Fmake_network_process): Use socklen_t, not int, |
| 4 | where POSIX says socklen_t is required in portable programs. | 6 | where POSIX says socklen_t is required in portable programs. |
| 5 | This fixes a porting bug on hosts like 64-bit HP-UX, where | 7 | This fixes a porting bug on hosts like 64-bit HP-UX, where |
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. */) | |||
| 2312 | (void) | 2312 | (void) |
| 2313 | { | 2313 | { |
| 2314 | int nfd; | 2314 | int nfd; |
| 2315 | int err = 0; | ||
| 2315 | 2316 | ||
| 2316 | if (!IS_DAEMON) | 2317 | if (!IS_DAEMON) |
| 2317 | error ("This function can only be called if emacs is run as a daemon"); | 2318 | 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. */) | |||
| 2324 | 2325 | ||
| 2325 | /* Get rid of stdin, stdout and stderr. */ | 2326 | /* Get rid of stdin, stdout and stderr. */ |
| 2326 | nfd = open ("/dev/null", O_RDWR); | 2327 | nfd = open ("/dev/null", O_RDWR); |
| 2327 | dup2 (nfd, 0); | 2328 | err |= nfd < 0; |
| 2328 | dup2 (nfd, 1); | 2329 | err |= dup2 (nfd, 0) < 0; |
| 2329 | dup2 (nfd, 2); | 2330 | err |= dup2 (nfd, 1) < 0; |
| 2330 | close (nfd); | 2331 | err |= dup2 (nfd, 2) < 0; |
| 2332 | err |= close (nfd) != 0; | ||
| 2331 | 2333 | ||
| 2332 | /* Closing the pipe will notify the parent that it can exit. | 2334 | /* Closing the pipe will notify the parent that it can exit. |
| 2333 | FIXME: In case some other process inherited the pipe, closing it here | 2335 | 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. */) | |||
| 2336 | Instead, we should probably close the pipe in start-process and | 2338 | Instead, we should probably close the pipe in start-process and |
| 2337 | call-process to make sure the pipe is never inherited by | 2339 | call-process to make sure the pipe is never inherited by |
| 2338 | subprocesses. */ | 2340 | subprocesses. */ |
| 2339 | write (daemon_pipe[1], "\n", 1); | 2341 | err |= write (daemon_pipe[1], "\n", 1) < 0; |
| 2340 | close (daemon_pipe[1]); | 2342 | err |= close (daemon_pipe[1]) != 0; |
| 2341 | /* Set it to an invalid value so we know we've already run this function. */ | 2343 | /* Set it to an invalid value so we know we've already run this function. */ |
| 2342 | daemon_pipe[1] = -1; | 2344 | daemon_pipe[1] = -1; |
| 2345 | |||
| 2346 | if (err) | ||
| 2347 | error ("I/O error during daemon initialization"); | ||
| 2343 | return Qt; | 2348 | return Qt; |
| 2344 | } | 2349 | } |
| 2345 | 2350 | ||