X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/b8f74366162596d45d12eec7ac01d251d274b887..83a119f8d892a790b25bd0d856df82fb25b0ba72:/src/emacs.c
diff --git a/src/emacs.c b/src/emacs.c
index 71d84efcbf..dc4c23b399 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -1,7 +1,7 @@
/* Fully extensible Emacs, running on Unix, intended for GNU.
-Copyright (C) 1985-1987, 1993-1995, 1997-1999, 2001-2013 Free Software
-Foundation, Inc.
+Copyright (C) 1985-1987, 1993-1995, 1997-1999, 2001-2013
+ Free Software Foundation, Inc.
This file is part of GNU Emacs.
@@ -27,12 +27,13 @@ along with GNU Emacs. If not, see . */
#include
#include
-#include
+#include
#include "lisp.h"
#ifdef WINDOWSNT
#include
+#include
#include "w32.h"
#include "w32heap.h"
#endif
@@ -40,9 +41,10 @@ along with GNU Emacs. If not, see . */
#if defined WINDOWSNT || defined HAVE_NTGUI
#include "w32select.h"
#include "w32font.h"
+#include "w32common.h"
#endif
-#if defined HAVE_NTGUI && defined CYGWIN
+#if defined CYGWIN
#include "cygw32.h"
#endif
@@ -94,10 +96,6 @@ extern void moncontrol (int mode);
#include
#endif
-#ifndef O_RDWR
-#define O_RDWR 2
-#endif
-
static const char emacs_version[] = VERSION;
static const char emacs_copyright[] = COPYRIGHT;
@@ -129,6 +127,8 @@ extern int malloc_set_state (void*);
/* True if the MALLOC_CHECK_ environment variable was set while
dumping. Used to work around a bug in glibc's malloc. */
static bool malloc_using_checking;
+#elif defined HAVE_PTHREAD && !defined SYSTEM_MALLOC
+extern void malloc_enable_thread (void);
#endif
Lisp_Object Qfile_name_handler_alist;
@@ -136,6 +136,7 @@ Lisp_Object Qfile_name_handler_alist;
Lisp_Object Qrisky_local_variable;
Lisp_Object Qkill_emacs;
+static Lisp_Object Qkill_emacs_hook;
/* If true, Emacs should not attempt to use a window-specific code,
but instead should use the virtual terminal under which it was started. */
@@ -200,10 +201,10 @@ int initial_argc;
static void sort_args (int argc, char **argv);
static void syms_of_emacs (void);
-/* MSVC needs each string be shorter than 2048 bytes, so the usage
+/* C89 needs each string be at most 509 characters, so the usage
strings below are split to not overflow this limit. */
-#define USAGE1 "\
-Usage: %s [OPTION-OR-FILENAME]...\n\
+static char const *const usage_message[] =
+ { "\
\n\
Run Emacs, the extensible, customizable, self-documenting real-time\n\
display editor. The recommended way to start Emacs for normal editing\n\
@@ -214,11 +215,15 @@ read the main documentation for these command-line arguments.\n\
\n\
Initialization options:\n\
\n\
+",
+ "\
--batch do not do interactive display; implies -q\n\
--chdir DIR change to directory DIR\n\
--daemon start a server in the background\n\
--debug-init enable Emacs Lisp debugger for init file\n\
--display, -d DISPLAY use X server DISPLAY\n\
+",
+ "\
--no-desktop do not load a saved desktop\n\
--no-init-file, -q load neither ~/.emacs nor default.el\n\
--no-shared-memory, -nl do not use shared memory\n\
@@ -226,14 +231,16 @@ Initialization options:\n\
--no-site-lisp, -nsl do not add site-lisp directories to load-path\n\
--no-splash do not display a splash screen on startup\n\
--no-window-system, -nw do not communicate with X, ignoring $DISPLAY\n\
+",
+ "\
--quick, -Q equivalent to:\n\
-q --no-site-file --no-site-lisp --no-splash\n\
--script FILE run FILE as an Emacs Lisp script\n\
--terminal, -t DEVICE use DEVICE for terminal I/O\n\
--user, -u USER load ~USER/.emacs instead of your own\n\
-\n%s"
-
-#define USAGE2 "\
+\n\
+",
+ "\
Action options:\n\
\n\
FILE visit FILE using find-file\n\
@@ -242,6 +249,8 @@ FILE visit FILE using find-file\n\
--directory, -L DIR add DIR to variable load-path\n\
--eval EXPR evaluate Emacs Lisp expression EXPR\n\
--execute EXPR evaluate Emacs Lisp expression EXPR\n\
+",
+ "\
--file FILE visit FILE using find-file\n\
--find-file FILE visit FILE using find-file\n\
--funcall, -f FUNC call Emacs Lisp function FUNC with no arguments\n\
@@ -249,9 +258,9 @@ FILE visit FILE using find-file\n\
--kill exit without asking for confirmation\n\
--load, -l FILE load Emacs Lisp FILE using the load function\n\
--visit FILE visit FILE using find-file\n\
-\n"
-
-#define USAGE3 "\
+\n\
+",
+ "\
Display options:\n\
\n\
--background-color, -bg COLOR window background color\n\
@@ -259,6 +268,8 @@ Display options:\n\
used for debugging Emacs\n\
--border-color, -bd COLOR main border color\n\
--border-width, -bw WIDTH width of main border\n\
+",
+ "\
--color, --color=MODE override color mode for character terminals;\n\
MODE defaults to `auto', and\n\
can also be `never', `always',\n\
@@ -266,17 +277,23 @@ Display options:\n\
--cursor-color, -cr COLOR color of the Emacs cursor indicating point\n\
--font, -fn FONT default font; must be fixed-width\n\
--foreground-color, -fg COLOR window foreground color\n\
+",
+ "\
--fullheight, -fh make the first frame high as the screen\n\
--fullscreen, -fs make the first frame fullscreen\n\
--fullwidth, -fw make the first frame wide as the screen\n\
--maximized, -mm make the first frame maximized\n\
--geometry, -g GEOMETRY window geometry\n\
+",
+ "\
--no-bitmap-icon, -nbi do not use picture of gnu for Emacs icon\n\
--iconic start Emacs in iconified state\n\
--internal-border, -ib WIDTH width between text and main border\n\
--line-spacing, -lsp PIXELS additional space to put between lines\n\
--mouse-color, -ms COLOR mouse cursor color in Emacs window\n\
--name NAME title for initial Emacs frame\n\
+",
+ "\
--no-blinking-cursor, -nbc disable blinking cursor\n\
--reverse-video, -r, -rv switch foreground and background\n\
--title, -T TITLE title for initial Emacs frame\n\
@@ -285,18 +302,19 @@ Display options:\n\
--parent-id XID set parent window\n\
--help display this help and exit\n\
--version output version information and exit\n\
-\n"
-
-#define USAGE4 "\
+\n\
+",
+ "\
You can generally also specify long option names with a single -; for\n\
example, -batch as well as --batch. You can use any unambiguous\n\
abbreviation for a --option.\n\
\n\
Various environment variables and window system resources also affect\n\
-Emacs' operation. See the main documentation.\n\
+the operation of Emacs. See the main documentation.\n\
\n\
Report bugs to bug-gnu-emacs@gnu.org. First, please see the Bugs\n\
section of the Emacs manual or the file BUGS.\n"
+ };
/* True if handling a fatal error already. */
@@ -307,6 +325,13 @@ bool fatal_error_in_progress;
static void *ns_pool;
#endif
+#if !HAVE_SETLOCALE
+static char *
+setlocale (int cat, char const *locale)
+{
+ return 0;
+}
+#endif
/* Report a fatal error due to signal SIG, output a backtrace of at
@@ -492,8 +517,7 @@ init_cmdargs (int argc, char **argv, int skip_args)
They are decoded in the function command-line after we know
locale-coding-system. */
Vcommand_line_args
- = Fcons (make_unibyte_string (argv[i], strlen (argv[i])),
- Vcommand_line_args);
+ = Fcons (build_unibyte_string (argv[i]), Vcommand_line_args);
}
unbind_to (count, Qnil);
@@ -519,34 +543,8 @@ DEFUN ("invocation-directory", Finvocation_directory, Sinvocation_directory,
#ifdef HAVE_TZSET
/* A valid but unlikely value for the TZ environment value.
It is OK (though a bit slower) if the user actually chooses this value. */
-static char dump_tz[] = "UtC0";
-#endif
-
-#ifndef ORDINARY_LINK
-/* We don't include crtbegin.o and crtend.o in the link,
- so these functions and variables might be missed.
- Provide dummy definitions to avoid error.
- (We don't have any real constructors or destructors.) */
-#ifdef __GNUC__
-
-/* Define a dummy function F. Declare F too, to pacify gcc
- -Wmissing-prototypes. */
-#define DEFINE_DUMMY_FUNCTION(f) \
- void f (void) ATTRIBUTE_CONST EXTERNALLY_VISIBLE; void f (void) {}
-
-#ifndef GCC_CTORS_IN_LIBC
-DEFINE_DUMMY_FUNCTION (__do_global_ctors)
-DEFINE_DUMMY_FUNCTION (__do_global_ctors_aux)
-DEFINE_DUMMY_FUNCTION (__do_global_dtors)
-/* GNU/Linux has a bug in its library; avoid an error. */
-#ifndef GNU_LINUX
-char * __CTOR_LIST__[2] EXTERNALLY_VISIBLE = { (char *) (-1), 0 };
-#endif
-char * __DTOR_LIST__[2] EXTERNALLY_VISIBLE = { (char *) (-1), 0 };
-#endif /* GCC_CTORS_IN_LIBC */
-DEFINE_DUMMY_FUNCTION (__main)
-#endif /* __GNUC__ */
-#endif /* ORDINARY_LINK */
+static char const dump_tz[] = "UtC0";
+#endif
/* Test whether the next argument in ARGV matches SSTR or a prefix of
LSTR (at least MINLEN characters). If so, then if VALPTR is non-null
@@ -656,6 +654,20 @@ void (*__malloc_initialize_hook) (void) EXTERNALLY_VISIBLE = malloc_initialize_h
#endif /* DOUG_LEA_MALLOC */
+/* Close standard output and standard error, reporting any write
+ errors as best we can. This is intended for use with atexit. */
+static void
+close_output_streams (void)
+{
+ if (close_stream (stdout) != 0)
+ {
+ emacs_perror ("Write error to standard output");
+ _exit (EXIT_FAILURE);
+ }
+
+ if (close_stream (stderr) != 0)
+ _exit (EXIT_FAILURE);
+}
/* ARGSUSED */
int
@@ -684,8 +696,9 @@ main (int argc, char **argv)
#endif
#ifdef G_SLICE_ALWAYS_MALLOC
- /* This is used by the Cygwin build. */
- setenv ("G_SLICE", "always-malloc", 1);
+ /* This is used by the Cygwin build. It's not needed starting with
+ cygwin-1.7.24, but it doesn't do any harm. */
+ xputenv ("G_SLICE=always-malloc");
#endif
#ifdef GNU_LINUX
@@ -701,6 +714,13 @@ main (int argc, char **argv)
}
#endif
+#if defined WINDOWSNT || defined HAVE_NTGUI
+ /* Set global variables used to detect Windows version. Do this as
+ early as possible. (unexw32.c calls this function as well, but
+ the additional call here is harmless.) */
+ cache_system_info ();
+#endif
+
#ifdef RUN_TIME_REMAP
if (initialized)
run_time_remap (argv[0]);
@@ -712,6 +732,8 @@ main (int argc, char **argv)
unexec_init_emacs_zone ();
#endif
+ atexit (close_output_streams);
+
sort_args (argc, argv);
argc = 0;
while (argv[argc]) argc++;
@@ -769,9 +791,8 @@ main (int argc, char **argv)
#ifdef HAVE_PERSONALITY_LINUX32
if (dumping && ! getenv ("EMACS_HEAP_EXEC"))
{
- static char heapexec[] = "EMACS_HEAP_EXEC=true";
/* Set this so we only do this once. */
- putenv (heapexec);
+ xputenv ("EMACS_HEAP_EXEC=true");
/* A flag to turn off address randomization which is introduced
in linux kernel shipped with fedora core 4 */
@@ -782,7 +803,7 @@ main (int argc, char **argv)
execvp (argv[0], argv);
/* If the exec fails, try to dump anyway. */
- perror ("execvp");
+ emacs_perror (argv[0]);
}
#endif /* HAVE_PERSONALITY_LINUX32 */
@@ -883,7 +904,7 @@ main (int argc, char **argv)
emacs_close (0);
emacs_close (1);
result = emacs_open (term, O_RDWR, 0);
- if (result < 0 || dup (0) < 0)
+ if (result < 0 || fcntl (0, F_DUPFD_CLOEXEC, 1) < 0)
{
char *errstring = strerror (errno);
fprintf (stderr, "%s: %s: %s\n", argv[0], term, errstring);
@@ -930,9 +951,10 @@ main (int argc, char **argv)
/* Handle the --help option, which gives a usage message. */
if (argmatch (argv, argc, "-help", "--help", 3, NULL, &skip_args))
{
- printf (USAGE1, argv[0], USAGE2);
- printf (USAGE3);
- printf (USAGE4);
+ int i;
+ printf ("Usage: %s [OPTION-OR-FILENAME]...\n", argv[0]);
+ for (i = 0; i < sizeof usage_message / sizeof *usage_message; i++)
+ fputs (usage_message[i], stdout);
exit (0);
}
@@ -963,7 +985,7 @@ main (int argc, char **argv)
use a pipe for synchronization. The parent waits for the child
to close its end of the pipe (using `daemon-initialized')
before exiting. */
- if (pipe (daemon_pipe) == -1)
+ if (emacs_pipe (daemon_pipe) != 0)
{
fprintf (stderr, "Cannot pipe!\n");
exit (1);
@@ -988,7 +1010,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
char buf[1];
/* Close unused writing end of the pipe. */
- close (daemon_pipe[1]);
+ emacs_close (daemon_pipe[1]);
/* Just wait for the child to close its end of the pipe. */
do
@@ -1008,13 +1030,13 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
exit (1);
}
- close (daemon_pipe[0]);
+ emacs_close (daemon_pipe[0]);
exit (0);
}
if (f < 0)
{
- fprintf (stderr, "Cannot fork!\n");
- exit (1);
+ emacs_perror ("fork");
+ exit (EXIT_CANCELED);
}
#ifdef DAEMON_MUST_EXEC
@@ -1031,14 +1053,14 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
if (! (0 <= fdStrlen && fdStrlen < sizeof fdStr))
{
fprintf (stderr, "daemon: child name too long\n");
- exit (1);
+ exit (EXIT_CANNOT_INVOKE);
}
argv[skip_args] = fdStr;
execvp (argv[0], argv);
- fprintf (stderr, "emacs daemon: exec failed: %d\n", errno);
- exit (1);
+ emacs_perror (argv[0]);
+ exit (errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE);
}
/* In exec'd: parse special dname into pipe and name info. */
@@ -1046,7 +1068,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
|| strlen (dname_arg) < 1 || strlen (dname_arg) > 70)
{
fprintf (stderr, "emacs daemon: daemon name absent or too long\n");
- exit (1);
+ exit (EXIT_CANNOT_INVOKE);
}
dname_arg2[0] = '\0';
sscanf (dname_arg, "\n%d,%d\n%s", &(daemon_pipe[0]), &(daemon_pipe[1]),
@@ -1058,34 +1080,31 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
if (dname_arg)
daemon_name = xstrdup (dname_arg);
/* Close unused reading end of the pipe. */
- close (daemon_pipe[0]);
- /* Make sure that the used end of the pipe is closed on exec, so
- that it is not accessible to programs started from .emacs. */
- fcntl (daemon_pipe[1], F_SETFD, FD_CLOEXEC);
+ emacs_close (daemon_pipe[0]);
-#ifdef HAVE_SETSID
setsid ();
-#endif
#else /* DOS_NT */
fprintf (stderr, "This platform does not support the -daemon flag.\n");
exit (1);
#endif /* DOS_NT */
}
-#if defined (HAVE_PTHREAD) && !defined (SYSTEM_MALLOC) && !defined (DOUG_LEA_MALLOC)
- if (! noninteractive)
- {
- extern void malloc_enable_thread (void);
-
- malloc_enable_thread ();
- }
+#if defined HAVE_PTHREAD && !defined SYSTEM_MALLOC && !defined DOUG_LEA_MALLOC
+# ifndef CANNOT_DUMP
+ /* Do not make gmalloc thread-safe when creating bootstrap-emacs, as
+ that causes an infinite recursive loop with FreeBSD. But do make
+ it thread-safe when creating emacs, otherwise bootstrap-emacs
+ fails on Cygwin. See Bug#14569. */
+ if (!noninteractive || initialized)
+# endif
+ malloc_enable_thread ();
#endif
init_signals (dumping);
noninteractive1 = noninteractive;
-/* Perform basic initializations (not merely interning symbols). */
+ /* Perform basic initializations (not merely interning symbols). */
if (!initialized)
{
@@ -1096,8 +1115,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
init_coding_once ();
init_syntax_once (); /* Create standard syntax table. */
init_category_once (); /* Create standard category table. */
- /* Must be done before init_buffer. */
- init_casetab_once ();
+ init_casetab_once (); /* Must be done before init_buffer_once. */
init_buffer_once (); /* Create buffer table and some buffers. */
init_minibuf_once (); /* Create list of minibuffers. */
/* Must precede init_window_once. */
@@ -1118,9 +1136,12 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
/* Called before syms_of_fileio, because it sets up Qerror_condition. */
syms_of_data ();
+ syms_of_fns (); /* Before syms_of_charset which uses hashtables. */
syms_of_fileio ();
/* Before syms_of_coding to initialize Vgc_cons_threshold. */
syms_of_alloc ();
+ /* May call Ffuncall and so GC, thus the latter should be initialized. */
+ init_print_once ();
/* Before syms_of_coding because it initializes Qcharsetp. */
syms_of_charset ();
/* Before init_window_once, because it sets up the
@@ -1129,7 +1150,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
init_window_once (); /* Init the window system. */
#ifdef HAVE_WINDOW_SYSTEM
- init_fringe_once (); /* Swap bitmaps if necessary. */
+ init_fringe_once (); /* Swap bitmaps if necessary. */
#endif /* HAVE_WINDOW_SYSTEM */
}
@@ -1253,8 +1274,15 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
tzset ();
#endif /* MSDOS */
+#ifdef HAVE_GFILENOTIFY
+ globals_of_gfilenotify ();
+#endif
+
#ifdef WINDOWSNT
globals_of_w32 ();
+#ifdef HAVE_W32NOTIFY
+ globals_of_w32notify ();
+#endif
/* Initialize environment from registry settings. */
init_environment (argv);
init_ntproc (dumping); /* must precede init_editfns. */
@@ -1276,7 +1304,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
don't pollute Vglobal_environment. */
/* Setting LANG here will defeat the startup locale processing... */
#ifdef AIX
- putenv ("LANG=C");
+ xputenv ("LANG=C");
#endif
init_buffer (); /* Init default directory of main buffer. */
@@ -1295,6 +1323,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
}
init_callproc (); /* Must follow init_cmdargs but not init_sys_modes. */
+ init_fileio ();
init_lread ();
#ifdef WINDOWSNT
/* Check to see if Emacs has been installed correctly. */
@@ -1312,7 +1341,6 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
syms_of_lread ();
syms_of_print ();
syms_of_eval ();
- syms_of_fns ();
syms_of_floatfns ();
syms_of_buffer ();
@@ -1351,7 +1379,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
#ifdef WINDOWSNT
syms_of_ntproc ();
#endif /* WINDOWSNT */
-#if defined CYGWIN && defined HAVE_NTGUI
+#if defined CYGWIN
syms_of_cygw32 ();
#endif
syms_of_window ();
@@ -1379,6 +1407,10 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
syms_of_xml ();
#endif
+#ifdef HAVE_ZLIB
+ syms_of_decompress ();
+#endif
+
syms_of_menu ();
#ifdef HAVE_NTGUI
@@ -1411,12 +1443,23 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
syms_of_gnutls ();
#endif
+#ifdef HAVE_GFILENOTIFY
+ syms_of_gfilenotify ();
+#endif /* HAVE_GFILENOTIFY */
+
+#ifdef HAVE_INOTIFY
+ syms_of_inotify ();
+#endif /* HAVE_INOTIFY */
+
#ifdef HAVE_DBUS
syms_of_dbusbind ();
#endif /* HAVE_DBUS */
#ifdef WINDOWSNT
syms_of_ntterm ();
+#ifdef HAVE_W32NOTIFY
+ syms_of_w32notify ();
+#endif /* HAVE_W32NOTIFY */
#endif /* WINDOWSNT */
syms_of_profiler ();
@@ -1463,12 +1506,11 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
char *file;
/* Handle -l loadup, args passed by Makefile. */
if (argmatch (argv, argc, "-l", "--load", 3, &file, &skip_args))
- Vtop_level = Fcons (intern_c_string ("load"),
- Fcons (build_string (file), Qnil));
+ Vtop_level = list2 (intern_c_string ("load"), build_string (file));
/* Unless next switch is -nl, load "loadup.el" first thing. */
if (! no_loadup)
- Vtop_level = Fcons (intern_c_string ("load"),
- Fcons (build_string ("loadup.el"), Qnil));
+ Vtop_level = list2 (intern_c_string ("load"),
+ build_string ("loadup.el"));
}
if (initialized)
@@ -1814,7 +1856,6 @@ all of which are called before Emacs is actually killed. */)
(Lisp_Object arg)
{
struct gcpro gcpro1;
- Lisp_Object hook;
int exit_code;
GCPRO1 (arg);
@@ -1822,9 +1863,10 @@ all of which are called before Emacs is actually killed. */)
if (feof (stdin))
arg = Qt;
- hook = intern ("kill-emacs-hook");
- Frun_hooks (1, &hook);
-
+ /* Fsignal calls emacs_abort () if it sees that waiting_for_input is
+ set. */
+ waiting_for_input = 0;
+ Frun_hooks (1, &Qkill_emacs_hook);
UNGCPRO;
#ifdef HAVE_X_WINDOWS
@@ -1842,14 +1884,16 @@ all of which are called before Emacs is actually killed. */)
kill it because we are exiting Emacs deliberately (not crashing).
Do it after shut_down_emacs, which does an auto-save. */
if (STRINGP (Vauto_save_list_file_name))
- unlink (SSDATA (Vauto_save_list_file_name));
+ {
+ Lisp_Object listfile;
+ listfile = Fexpand_file_name (Vauto_save_list_file_name, Qnil);
+ unlink (SSDATA (listfile));
+ }
if (INTEGERP (arg))
exit_code = (XINT (arg) < 0
? XINT (arg) | INT_MIN
: XINT (arg) & INT_MAX);
- else if (noninteractive && (fflush (stdout) || ferror (stdout)))
- exit_code = EXIT_FAILURE;
else
exit_code = EXIT_SUCCESS;
exit (exit_code);
@@ -1879,7 +1923,7 @@ shut_down_emacs (int sig, Lisp_Object stuff)
/* If we are controlling the terminal, reset terminal modes. */
#ifndef DOS_NT
{
- pid_t pgrp = EMACS_GETPGRP (0);
+ pid_t pgrp = getpgrp ();
pid_t tpgrp = tcgetpgrp (0);
if ((tpgrp != -1) && tpgrp == pgrp)
{
@@ -1890,8 +1934,8 @@ shut_down_emacs (int sig, Lisp_Object stuff)
char buf[sizeof format - 2 + INT_STRLEN_BOUND (int)];
int buflen = sprintf (buf, format, sig);
char const *sig_desc = safe_strsignal (sig);
- ignore_value (write (STDERR_FILENO, buf, buflen));
- ignore_value (write (STDERR_FILENO, sig_desc, strlen (sig_desc)));
+ emacs_write (STDERR_FILENO, buf, buflen);
+ emacs_write (STDERR_FILENO, sig_desc, strlen (sig_desc));
}
}
}
@@ -2126,7 +2170,7 @@ decode_env_path (const char *evarname, const char *defalt)
{
char *path_copy = alloca (strlen (path) + 1);
strcpy (path_copy, path);
- dostounix_filename (path_copy);
+ dostounix_filename (path_copy, 0);
path = path_copy;
}
#endif
@@ -2208,12 +2252,12 @@ from the parent process and its tty file descriptors. */)
error ("This function can only be called after loading the init files");
/* Get rid of stdin, stdout and stderr. */
- nfd = open ("/dev/null", O_RDWR);
+ nfd = emacs_open ("/dev/null", O_RDWR, 0);
err |= nfd < 0;
err |= dup2 (nfd, 0) < 0;
err |= dup2 (nfd, 1) < 0;
err |= dup2 (nfd, 2) < 0;
- err |= close (nfd) != 0;
+ err |= emacs_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
@@ -2223,7 +2267,7 @@ from the parent process and its tty file descriptors. */)
call-process to make sure the pipe is never inherited by
subprocesses. */
err |= write (daemon_pipe[1], "\n", 1) < 0;
- err |= close (daemon_pipe[1]) != 0;
+ err |= emacs_close (daemon_pipe[1]) != 0;
/* Set it to an invalid value so we know we've already run this function. */
daemon_pipe[1] = -1;
@@ -2238,6 +2282,7 @@ syms_of_emacs (void)
DEFSYM (Qfile_name_handler_alist, "file-name-handler-alist");
DEFSYM (Qrisky_local_variable, "risky-local-variable");
DEFSYM (Qkill_emacs, "kill-emacs");
+ DEFSYM (Qkill_emacs_hook, "kill-emacs-hook");
#ifndef CANNOT_DUMP
defsubr (&Sdump_emacs);