#include "syssignal.h"
#include "systime.h"
-static void emacs_get_tty (int, struct emacs_tty *);
-static int emacs_set_tty (int, struct emacs_tty *, bool);
+void emacs_get_tty (int, struct emacs_tty *) EXTERNALLY_VISIBLE;
+int emacs_set_tty (int, struct emacs_tty *, bool) EXTERNALLY_VISIBLE;
/* ULLONG_MAX is missing on Red Hat Linux 7.3; see Bug#11781. */
#ifndef ULLONG_MAX
void
stuff_char (char c)
{
- if (! FRAME_TERMCAP_P (SELECTED_FRAME ()))
+ if (! (FRAMEP (selected_frame)
+ && FRAME_LIVE_P (XFRAME (selected_frame))
+ && FRAME_TERMCAP_P (XFRAME (selected_frame))))
return;
/* Should perhaps error if in batch mode */
signal (SIGIO, SIG_IGN);
#endif
}
+\f
+#ifndef MSDOS
+/* Block SIGCHLD. */
+
+void
+block_child_signal (sigset_t *oldset)
+{
+ sigset_t blocked;
+ sigemptyset (&blocked);
+ sigaddset (&blocked, SIGCHLD);
+ sigaddset (&blocked, SIGINT);
+ pthread_sigmask (SIG_BLOCK, &blocked, oldset);
+}
+
+/* Unblock SIGCHLD. */
+
+void
+unblock_child_signal (sigset_t const *oldset)
+{
+ pthread_sigmask (SIG_SETMASK, oldset, 0);
+}
+#endif /* !MSDOS */
\f
/* Saving and restoring the process group of Emacs's terminal. */
/* Set *TC to the parameters associated with the terminal FD,
or clear it if the parameters are not available. */
-static void
+void
emacs_get_tty (int fd, struct emacs_tty *settings)
{
/* Retrieve the primary parameters - baud rate, character size, etcetera. */
-#ifndef DOS_NT
- /* We have those nifty POSIX tcmumbleattr functions. */
memset (&settings->main, 0, sizeof (settings->main));
+#ifdef DOS_NT
+#ifdef WINDOWSNT
+ HANDLE h = (HANDLE)_get_osfhandle (fd);
+ DWORD console_mode;
+
+ if (h && h != INVALID_HANDLE_VALUE)
+ {
+ if (GetConsoleMode (h, &console_mode))
+ settings->main = console_mode;
+ }
+#endif /* WINDOWSNT */
+#else /* !DOS_NT */
+ /* We have those nifty POSIX tcmumbleattr functions. */
tcgetattr (fd, &settings->main);
#endif
}
*SETTINGS. If FLUSHP, discard input.
Return 0 if all went well, and -1 (setting errno) if anything failed. */
-static int
+int
emacs_set_tty (int fd, struct emacs_tty *settings, bool flushp)
{
/* Set the primary parameters - baud rate, character size, etcetera. */
-#ifndef DOS_NT
+#ifdef DOS_NT
+#ifdef WINDOWSNT
+ HANDLE h = (HANDLE)_get_osfhandle (fd);
+
+ if (h && h != INVALID_HANDLE_VALUE)
+ {
+ DWORD new_mode;
+
+ /* Assume the handle is open for input. */
+ if (flushp)
+ FlushConsoleInputBuffer (h);
+ new_mode = settings->main;
+ SetConsoleMode (h, new_mode);
+ }
+#endif /* WINDOWSNT */
+#else /* !DOS_NT */
int i;
/* We have those nifty POSIX tcmumbleattr functions.
William J. Smith <wjs@wiis.wang.com> writes:
return 0;
#endif /* DOS_NT */
}
+
+/* Discard echoing. */
+
+void
+suppress_echo_on_tty (int fd)
+{
+ struct emacs_tty etty;
+
+ emacs_get_tty (fd, &etty);
+#ifdef DOS_NT
+ /* Set raw input mode. */
+ etty.main = 0;
+#else
+ etty.main.c_lflag &= ~ICANON; /* Disable buffering */
+ etty.main.c_lflag &= ~ECHO; /* Disable echoing */
+#endif /* ! WINDOWSNT */
+ emacs_set_tty (fd, &etty, 0);
+}
\f
/* Get terminal size from system.
Store number of lines into *HEIGHTP and width into *WIDTHP.
int i;
tty_turn_off_insert (tty_out);
- for (i = curX (tty_out); i < FrameCols (tty_out) - 1; i++)
+ for (i = cursorX (tty_out); i < FrameCols (tty_out) - 1; i++)
{
fputc (' ', tty_out->output);
}
static _Noreturn void
handle_arith_signal (int sig)
{
- sigset_t blocked;
- sigemptyset (&blocked);
- sigaddset (&blocked, sig);
- pthread_sigmask (SIG_UNBLOCK, &blocked, 0);
+ pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
xsignal0 (Qarith_error);
}