diff options
author | Eli Zaretskii <eliz@gnu.org> | 2022-04-18 10:05:15 +0300 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2022-04-18 10:05:15 +0300 |
commit | 2363366862d0ed7334aff38ebcd5f02d26e33402 (patch) | |
tree | 297d47ded31c8f417a4bc3401ea9481642816403 /src/w32.c | |
parent | 5b5608c61446d78be3415fe8fce6a09142989f3f (diff) | |
download | emacs-2363366862d0ed7334aff38ebcd5f02d26e33402.tar.gz emacs-2363366862d0ed7334aff38ebcd5f02d26e33402.tar.bz2 emacs-2363366862d0ed7334aff38ebcd5f02d26e33402.zip |
Fix 'restart-emacs' in -nw mode on MS-Windows
* src/w32.c (openat): #ifdef away: not used.
(w32_reexec_emacs): Kludgey solution for restarting Emacs in the
"-nw" mode.
Diffstat (limited to 'src/w32.c')
-rw-r--r-- | src/w32.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/w32.c b/src/w32.c index ae1d77a021a..e4237579d84 100644 --- a/src/w32.c +++ b/src/w32.c @@ -4640,6 +4640,9 @@ sys_open (const char * path, int oflag, int mode) return res; } +/* This is not currently used, but might be needed again at some + point; DO NOT DELETE! */ +#if 0 int openat (int fd, const char * path, int oflag, int mode) { @@ -4660,6 +4663,7 @@ openat (int fd, const char * path, int oflag, int mode) return sys_open (path, oflag, mode); } +#endif int fchmod (int fd, mode_t mode) @@ -10623,12 +10627,6 @@ realpath (const char *file_name, char *resolved_name) int w32_reexec_emacs (char *cmd_line, const char *wdir) { - if (inhibit_window_system) - { - errno = ENOSYS; - return -1; /* FIXME! */ - } - STARTUPINFO si; SECURITY_ATTRIBUTES sec_attrs; BOOL status; @@ -10643,12 +10641,28 @@ w32_reexec_emacs (char *cmd_line, const char *wdir) line specifies the program as a relative file name. */ chdir (wdir); + /* This is a kludge: it causes the restarted "emacs -nw" to have a + new console window created for it, and that new window might have + different (default) properties, not the ones of the parent + process's console window. But without this, restarting Emacs in + the -nw mode simply doesn't work. FIXME! */ + if (inhibit_window_system) + { + if (!FreeConsole ()) + { + errno = ENOEXEC; + return -1; + } + } + status = CreateProcess (NULL, /* program */ cmd_line, /* command line */ &sec_attrs, /* process attributes */ NULL, /* thread attributes */ TRUE, /* inherit handles? */ - NORMAL_PRIORITY_CLASS, + inhibit_window_system + ? 0 /* inherit parent's console */ + : NORMAL_PRIORITY_CLASS, NULL, /* environment */ wdir, /* initial directory */ &si, /* startup info */ |