summaryrefslogtreecommitdiff
path: root/src/emacs.c
diff options
context:
space:
mode:
authorJan Djärv <jan.h.d@swipnet.se>2010-05-02 20:44:04 +0200
committerJan Djärv <jan.h.d@swipnet.se>2010-05-02 20:44:04 +0200
commitf63d0028c0cb44c5bf4ca7f36b66ab19595f6ecc (patch)
treea72ebe53b4ac0a453ee7b37a37f61cfdcc264cc8 /src/emacs.c
parent8f92b8ad07a0af0d0fe7784feaa56cf1ff5b16f9 (diff)
downloademacs-f63d0028c0cb44c5bf4ca7f36b66ab19595f6ecc.tar.gz
Run kill-emacs when exiting for display closed or SIGTERM/HUP.
* xsmfns.c (CHDIR_OPT): New define. (smc_save_yourself_CB): Add CHDIR_OPT to options to use when restarting emacs. * xterm.c (x_connection_closed): Call Fkill_emacs instead of shut_down_emacs. * emacs.c (USAGE1): Mention --chdir. (main): Handle --chdir. (standard_args): Add --chdir. (fatal_error_signal): Call Fkill_emacs for SIGTERM and SIGHUP (Bug #5552). * cmdargs.texi (Initial Options): Mention --chdir.
Diffstat (limited to 'src/emacs.c')
-rw-r--r--src/emacs.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/emacs.c b/src/emacs.c
index 400a6b0e594..d40ff3662f0 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -268,6 +268,7 @@ read the main documentation for these command-line arguments.\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\
@@ -385,6 +386,9 @@ fatal_error_signal (sig)
{
fatal_error_in_progress = 1;
+ if (sig == SIGTERM || sig == SIGHUP)
+ Fkill_emacs (make_number (sig));
+
shut_down_emacs (sig, 0, Qnil);
}
@@ -765,6 +769,7 @@ main (int argc, char **argv)
#ifdef NS_IMPL_COCOA
char dname_arg2[80];
#endif
+ char *ch_to_dir;
#if GC_MARK_STACK
extern Lisp_Object *stack_base;
@@ -832,6 +837,14 @@ main (int argc, char **argv)
exit (0);
}
}
+ if (argmatch (argv, argc, "-chdir", "--chdir", 2, &ch_to_dir, &skip_args))
+ if (chdir (ch_to_dir) == -1)
+ {
+ fprintf (stderr, "%s: Can't chdir to %s: %s\n",
+ argv[0], ch_to_dir, strerror (errno));
+ exit (1);
+ }
+
#ifdef HAVE_PERSONALITY_LINUX32
if (!initialized
@@ -1802,6 +1815,7 @@ struct standard_args
const struct standard_args standard_args[] =
{
{ "-version", "--version", 150, 0 },
+ { "-chdir", "--chdir", 130, 1 },
{ "-t", "--terminal", 120, 1 },
{ "-nw", "--no-window-system", 110, 0 },
{ "-nw", "--no-windows", 110, 0 },