diff options
Diffstat (limited to 'src/emacs.c')
| -rw-r--r-- | src/emacs.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/emacs.c b/src/emacs.c index 052f22ea622..6bdd2550ed1 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -308,7 +308,7 @@ pthread_t main_thread; | |||
| 308 | 308 | ||
| 309 | 309 | ||
| 310 | /* Handle bus errors, invalid instruction, etc. */ | 310 | /* Handle bus errors, invalid instruction, etc. */ |
| 311 | SIGTYPE | 311 | void |
| 312 | fatal_error_signal (int sig) | 312 | fatal_error_signal (int sig) |
| 313 | { | 313 | { |
| 314 | SIGNAL_THREAD_CHECK (sig); | 314 | SIGNAL_THREAD_CHECK (sig); |
| @@ -345,7 +345,7 @@ fatal_error_signal (int sig) | |||
| 345 | #ifdef SIGDANGER | 345 | #ifdef SIGDANGER |
| 346 | 346 | ||
| 347 | /* Handler for SIGDANGER. */ | 347 | /* Handler for SIGDANGER. */ |
| 348 | SIGTYPE | 348 | void |
| 349 | memory_warning_signal (sig) | 349 | memory_warning_signal (sig) |
| 350 | int sig; | 350 | int sig; |
| 351 | { | 351 | { |
| @@ -1972,14 +1972,15 @@ all of which are called before Emacs is actually killed. */) | |||
| 1972 | (Lisp_Object arg) | 1972 | (Lisp_Object arg) |
| 1973 | { | 1973 | { |
| 1974 | struct gcpro gcpro1; | 1974 | struct gcpro gcpro1; |
| 1975 | Lisp_Object hook; | ||
| 1975 | 1976 | ||
| 1976 | GCPRO1 (arg); | 1977 | GCPRO1 (arg); |
| 1977 | 1978 | ||
| 1978 | if (feof (stdin)) | 1979 | if (feof (stdin)) |
| 1979 | arg = Qt; | 1980 | arg = Qt; |
| 1980 | 1981 | ||
| 1981 | if (!NILP (Vrun_hooks)) | 1982 | hook = intern ("kill-emacs-hook"); |
| 1982 | call1 (Vrun_hooks, intern ("kill-emacs-hook")); | 1983 | Frun_hooks (1, &hook); |
| 1983 | 1984 | ||
| 1984 | UNGCPRO; | 1985 | UNGCPRO; |
| 1985 | 1986 | ||
| @@ -2312,6 +2313,7 @@ from the parent process and its tty file descriptors. */) | |||
| 2312 | (void) | 2313 | (void) |
| 2313 | { | 2314 | { |
| 2314 | int nfd; | 2315 | int nfd; |
| 2316 | int err = 0; | ||
| 2315 | 2317 | ||
| 2316 | if (!IS_DAEMON) | 2318 | if (!IS_DAEMON) |
| 2317 | error ("This function can only be called if emacs is run as a daemon"); | 2319 | error ("This function can only be called if emacs is run as a daemon"); |
| @@ -2324,10 +2326,11 @@ from the parent process and its tty file descriptors. */) | |||
| 2324 | 2326 | ||
| 2325 | /* Get rid of stdin, stdout and stderr. */ | 2327 | /* Get rid of stdin, stdout and stderr. */ |
| 2326 | nfd = open ("/dev/null", O_RDWR); | 2328 | nfd = open ("/dev/null", O_RDWR); |
| 2327 | dup2 (nfd, 0); | 2329 | err |= nfd < 0; |
| 2328 | dup2 (nfd, 1); | 2330 | err |= dup2 (nfd, 0) < 0; |
| 2329 | dup2 (nfd, 2); | 2331 | err |= dup2 (nfd, 1) < 0; |
| 2330 | close (nfd); | 2332 | err |= dup2 (nfd, 2) < 0; |
| 2333 | err |= close (nfd) != 0; | ||
| 2331 | 2334 | ||
| 2332 | /* Closing the pipe will notify the parent that it can exit. | 2335 | /* Closing the pipe will notify the parent that it can exit. |
| 2333 | FIXME: In case some other process inherited the pipe, closing it here | 2336 | FIXME: In case some other process inherited the pipe, closing it here |
| @@ -2336,10 +2339,13 @@ from the parent process and its tty file descriptors. */) | |||
| 2336 | Instead, we should probably close the pipe in start-process and | 2339 | Instead, we should probably close the pipe in start-process and |
| 2337 | call-process to make sure the pipe is never inherited by | 2340 | call-process to make sure the pipe is never inherited by |
| 2338 | subprocesses. */ | 2341 | subprocesses. */ |
| 2339 | write (daemon_pipe[1], "\n", 1); | 2342 | err |= write (daemon_pipe[1], "\n", 1) < 0; |
| 2340 | close (daemon_pipe[1]); | 2343 | err |= close (daemon_pipe[1]) != 0; |
| 2341 | /* Set it to an invalid value so we know we've already run this function. */ | 2344 | /* Set it to an invalid value so we know we've already run this function. */ |
| 2342 | daemon_pipe[1] = -1; | 2345 | daemon_pipe[1] = -1; |
| 2346 | |||
| 2347 | if (err) | ||
| 2348 | error ("I/O error during daemon initialization"); | ||
| 2343 | return Qt; | 2349 | return Qt; |
| 2344 | } | 2350 | } |
| 2345 | 2351 | ||