diff options
| author | Paul Eggert | 2013-07-09 00:04:48 -0700 |
|---|---|---|
| committer | Paul Eggert | 2013-07-09 00:04:48 -0700 |
| commit | 4ebbdd6712c1966406b40d2673464949775cbd7a (patch) | |
| tree | 08667dd241629ca55c2c30ce19777bd7ec107cfa /src/emacs.c | |
| parent | 584ee3fc72260acb3cc83f4d1a047b733a08ca17 (diff) | |
| download | emacs-4ebbdd6712c1966406b40d2673464949775cbd7a.tar.gz emacs-4ebbdd6712c1966406b40d2673464949775cbd7a.zip | |
Handle errno and exit status a bit more carefully.
* lib/ignore-value.h: Remove this gnulib-imported file.
* lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
* admin/merge-gnulib (GNULIB_MODULES): Remove ignore-value.
* src/callproc.c (child_setup) [!DOS_NT]: Don't try to stuff an error
number into an exit status. Instead, use EXIT_CANCELED.
(child_setup) [!MSDOS]: Avoid possible deadlock with vfork.
* src/callproc.c (relocate_fd):
* src/emacs.c (close_output_streams, main):
* src/process.c (create_process):
* src/sysdep.c (sys_subshell) [!DOS_NT || !WINDOWSNT]:
Use emacs_perror for simplicity.
* src/callproc.c (relocate_fd, main):
* src/sysdep.c (sys_subshell):
Exit with EXIT_CANCELED etc., not 1, when exec setup fails.
(shut_down_emacs): Use emacs_write, not write.
* src/emacs.c, src/sysdep.c: Don't include <ignore-value.h>.
* src/fileio.c (Fcopy_file, e_write):
* src/nsterm.m (ns_select):
* src/process.c (send_process):
* src/sound.c (vox_write):
Use emacs_write_sig, not emacs_write.
* src/lisp.h (emacs_write_sig, emacs_perror): New decls.
* src/process.h (EXIT_CANCELED), EXIT_CANNOT_INVOKE, EXIT_ENOENT):
New constants.
* src/sysdep.c (emacs_backtrace): Use emacs_write, not ignore_value
of write.
(emacs_full_write): New function.
(emacs_write): Rewrite to use it.
(emacswrite_sig, emacs_perror): New functions.
* src/xrdb.c (fatal): Don't invoke perror, since errno might be garbage.
Diffstat (limited to 'src/emacs.c')
| -rw-r--r-- | src/emacs.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/emacs.c b/src/emacs.c index edf98d8cdb5..ee72095f705 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -28,7 +28,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 28 | #include <unistd.h> | 28 | #include <unistd.h> |
| 29 | 29 | ||
| 30 | #include <close-stream.h> | 30 | #include <close-stream.h> |
| 31 | #include <ignore-value.h> | ||
| 32 | 31 | ||
| 33 | #include "lisp.h" | 32 | #include "lisp.h" |
| 34 | 33 | ||
| @@ -646,9 +645,7 @@ close_output_streams (void) | |||
| 646 | { | 645 | { |
| 647 | if (close_stream (stdout) != 0) | 646 | if (close_stream (stdout) != 0) |
| 648 | { | 647 | { |
| 649 | fprintf (stderr, "Write error to standard output: %s\n", | 648 | emacs_perror ("Write error to standard output"); |
| 650 | strerror (errno)); | ||
| 651 | fflush (stderr); | ||
| 652 | _exit (EXIT_FAILURE); | 649 | _exit (EXIT_FAILURE); |
| 653 | } | 650 | } |
| 654 | 651 | ||
| @@ -789,7 +786,7 @@ main (int argc, char **argv) | |||
| 789 | execvp (argv[0], argv); | 786 | execvp (argv[0], argv); |
| 790 | 787 | ||
| 791 | /* If the exec fails, try to dump anyway. */ | 788 | /* If the exec fails, try to dump anyway. */ |
| 792 | perror ("execvp"); | 789 | emacs_perror (argv[0]); |
| 793 | } | 790 | } |
| 794 | #endif /* HAVE_PERSONALITY_LINUX32 */ | 791 | #endif /* HAVE_PERSONALITY_LINUX32 */ |
| 795 | 792 | ||
| @@ -1020,8 +1017,8 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem | |||
| 1020 | } | 1017 | } |
| 1021 | if (f < 0) | 1018 | if (f < 0) |
| 1022 | { | 1019 | { |
| 1023 | fprintf (stderr, "Cannot fork!\n"); | 1020 | emacs_perror ("fork"); |
| 1024 | exit (1); | 1021 | exit (EXIT_CANCELED); |
| 1025 | } | 1022 | } |
| 1026 | 1023 | ||
| 1027 | #ifdef DAEMON_MUST_EXEC | 1024 | #ifdef DAEMON_MUST_EXEC |
| @@ -1038,14 +1035,14 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem | |||
| 1038 | if (! (0 <= fdStrlen && fdStrlen < sizeof fdStr)) | 1035 | if (! (0 <= fdStrlen && fdStrlen < sizeof fdStr)) |
| 1039 | { | 1036 | { |
| 1040 | fprintf (stderr, "daemon: child name too long\n"); | 1037 | fprintf (stderr, "daemon: child name too long\n"); |
| 1041 | exit (1); | 1038 | exit (EXIT_CANNOT_INVOKE); |
| 1042 | } | 1039 | } |
| 1043 | 1040 | ||
| 1044 | argv[skip_args] = fdStr; | 1041 | argv[skip_args] = fdStr; |
| 1045 | 1042 | ||
| 1046 | execvp (argv[0], argv); | 1043 | execvp (argv[0], argv); |
| 1047 | fprintf (stderr, "emacs daemon: exec failed: %d\n", errno); | 1044 | emacs_perror (argv[0]); |
| 1048 | exit (1); | 1045 | exit (errno == ENOENT : EXIT_ENOENT : EXIT_CANNOT_INVOKE); |
| 1049 | } | 1046 | } |
| 1050 | 1047 | ||
| 1051 | /* In exec'd: parse special dname into pipe and name info. */ | 1048 | /* In exec'd: parse special dname into pipe and name info. */ |
| @@ -1053,7 +1050,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem | |||
| 1053 | || strlen (dname_arg) < 1 || strlen (dname_arg) > 70) | 1050 | || strlen (dname_arg) < 1 || strlen (dname_arg) > 70) |
| 1054 | { | 1051 | { |
| 1055 | fprintf (stderr, "emacs daemon: daemon name absent or too long\n"); | 1052 | fprintf (stderr, "emacs daemon: daemon name absent or too long\n"); |
| 1056 | exit (1); | 1053 | exit (EXIT_CANNOT_INVOKE); |
| 1057 | } | 1054 | } |
| 1058 | dname_arg2[0] = '\0'; | 1055 | dname_arg2[0] = '\0'; |
| 1059 | sscanf (dname_arg, "\n%d,%d\n%s", &(daemon_pipe[0]), &(daemon_pipe[1]), | 1056 | sscanf (dname_arg, "\n%d,%d\n%s", &(daemon_pipe[0]), &(daemon_pipe[1]), |
| @@ -1916,8 +1913,8 @@ shut_down_emacs (int sig, Lisp_Object stuff) | |||
| 1916 | char buf[sizeof format - 2 + INT_STRLEN_BOUND (int)]; | 1913 | char buf[sizeof format - 2 + INT_STRLEN_BOUND (int)]; |
| 1917 | int buflen = sprintf (buf, format, sig); | 1914 | int buflen = sprintf (buf, format, sig); |
| 1918 | char const *sig_desc = safe_strsignal (sig); | 1915 | char const *sig_desc = safe_strsignal (sig); |
| 1919 | ignore_value (write (STDERR_FILENO, buf, buflen)); | 1916 | emacs_write (STDERR_FILENO, buf, buflen); |
| 1920 | ignore_value (write (STDERR_FILENO, sig_desc, strlen (sig_desc))); | 1917 | emacs_write (STDERR_FILENO, sig_desc, strlen (sig_desc)); |
| 1921 | } | 1918 | } |
| 1922 | } | 1919 | } |
| 1923 | } | 1920 | } |