/* 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-2014 Free Software
+Foundation, Inc.
This file is part of GNU Emacs.
on subsequent starts. */
bool initialized;
+/* Set to true if this instance of Emacs might dump. */
+bool might_dump;
+
#ifdef DARWIN_OS
extern void unexec_init_emacs_zone (void);
#endif
{
Lisp_Object found;
int yes = openp (Vexec_path, Vinvocation_name,
- Vexec_suffixes, &found, make_number (X_OK));
+ Vexec_suffixes, &found, make_number (X_OK), false);
if (yes == 1)
{
/* Add /: to the front of the name
xputenv ("G_SLICE=always-malloc");
#endif
+#ifndef CANNOT_DUMP
+ might_dump = !initialized;
+#endif
+
#ifdef GNU_LINUX
if (!initialized)
{
early as possible. (unexw32.c calls this function as well, but
the additional call here is harmless.) */
cache_system_info ();
+#ifdef WINDOWSNT
+ /* On Windows 9X, we have to load UNICOWS.DLL as early as possible,
+ to have non-stub implementations of APIs we need to convert file
+ names between UTF-8 and the system's ANSI codepage. */
+ maybe_load_unicows_dll ();
+#endif
#endif
#ifdef RUN_TIME_REMAP
exit (0);
}
+ /* Make sure IS_DAEMON starts up as false. */
+ daemon_pipe[1] = 0;
+
if (argmatch (argv, argc, "-daemon", "--daemon", 5, NULL, &skip_args)
|| argmatch (argv, argc, "-daemon", "--daemon", 5, &dname_arg, &skip_args))
{
argv[skip_args] = fdStr;
+ fcntl (daemon_pipe[0], F_SETFD, 0);
+ fcntl (daemon_pipe[1], F_SETFD, 0);
execvp (argv[0], argv);
emacs_perror (argv[0]);
exit (errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE);
sscanf (dname_arg, "\n%d,%d\n%s", &(daemon_pipe[0]), &(daemon_pipe[1]),
dname_arg2);
dname_arg = *dname_arg2 ? dname_arg2 : NULL;
+ fcntl (daemon_pipe[1], F_SETFD, FD_CLOEXEC);
}
#endif /* DAEMON_MUST_EXEC */
#ifdef HAVE_NS
ns_pool = ns_alloc_autorelease_pool ();
#ifdef NS_IMPL_GNUSTEP
- /* GNUStep stupidly resets our locale settings after we made them. */
+ /* GNUstep stupidly resets our locale settings after we made them. */
fixup_locale ();
#endif
if (! noninteractive)
error ("Dumping Emacs works only in batch mode");
+ if (!might_dump)
+ error ("Emacs can be dumped only once");
+
#ifdef GNU_LINUX
/* Warn if the gap between BSS end and heap start is larger than this. */
Vlibrary_cache = Qnil;
staticpro (&Vlibrary_cache);
#endif
-
- /* Make sure IS_DAEMON starts up as false. */
- daemon_pipe[1] = 0;
}