/* Interfaces to system-dependent kernel and library entries.
- Copyright (C) 1985, 86,87,88,93,94,95, 1999, 2000, 2001
- Free Software Foundation, Inc.
+ Copyright (C) 1985, 1986, 1987, 1988, 1993, 1994, 1995, 1999, 2000, 2001,
+ 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Emacs.
#endif
#include <signal.h>
+#include <stdio.h>
#include <setjmp.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#endif /* not WINDOWSNT */
-#ifdef HAVE_CARBON
-#define read sys_read
-#endif
-
/* Does anyone other than VMS need this? */
#ifndef fwrite
#define sys_fwrite fwrite
#undef fwrite
#endif
-#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
-/* Get _POSIX_VDISABLE, if it is available. */
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-
#ifdef HAVE_SETPGID
#if !defined (USG) || defined (BSD_PGRPS)
#undef setpgrp
s.main.c_cflag = (s.main.c_cflag & ~CBAUD) | B9600; /* baud rate sanity */
#endif /* HPUX */
+#ifdef SIGNALS_VIA_CHARACTERS
+ /* the QUIT and INTR character are used in process_send_signal
+ so set them here to something useful. */
+ if (s.main.c_cc[VQUIT] == CDISABLE)
+ s.main.c_cc[VQUIT] = '\\'&037; /* Control-\ */
+ if (s.main.c_cc[VINTR] == CDISABLE)
+ s.main.c_cc[VINTR] = 'C'&037; /* Control-C */
+#endif /* not SIGNALS_VIA_CHARACTERS */
+
#ifdef AIX
/* AIX enhanced edit loses NULs, so disable it */
#ifndef IBMR2AIX
don't ignore break, but don't signal either, so it looks like NUL. */
s.main.c_iflag &= ~IGNBRK;
s.main.c_iflag &= ~BRKINT;
+ /* rms: Formerly it set s.main.c_cc[VINTR] to 0377 here
+ unconditionally. Then a SIGNALS_VIA_CHARACTERS conditional
+ would force it to 0377. That looks like duplicated code. */
+#ifndef SIGNALS_VIA_CHARACTERS
/* QUIT and INTR work better as signals, so disable character forms */
- s.main.c_cc[VINTR] = 0377;
-#ifdef SIGNALS_VIA_CHARACTERS
- /* the QUIT and INTR character are used in process_send_signal
- so set them here to something useful. */
- if (s.main.c_cc[VQUIT] == 0377)
- s.main.c_cc[VQUIT] = '\\'&037; /* Control-\ */
- if (s.main.c_cc[VINTR] == 0377)
- s.main.c_cc[VINTR] = 'C'&037; /* Control-C */
-#else /* no TIOCGPGRP or no TIOCGLTC or no TIOCGETC */
- /* QUIT and INTR work better as signals, so disable character forms */
- s.main.c_cc[VQUIT] = 0377;
- s.main.c_cc[VINTR] = 0377;
+ s.main.c_cc[VQUIT] = CDISABLE;
+ s.main.c_cc[VINTR] = CDISABLE;
s.main.c_lflag &= ~ISIG;
#endif /* no TIOCGPGRP or no TIOCGLTC or no TIOCGETC */
- s.main.c_cc[VEOL] = 0377;
+ s.main.c_cc[VEOL] = CDISABLE;
s.main.c_cflag = (s.main.c_cflag & ~CBAUD) | B9600; /* baud rate sanity */
#endif /* AIX */
if (pid == -1)
write (1, "Can't execute subshell", 22);
#else /* not WINDOWSNT */
- execlp (sh, sh, 0);
+ execlp (sh, sh, (char *) 0);
write (1, "Can't execute subshell", 22);
_exit (1);
#endif /* not WINDOWSNT */
tty.main.c_line = 0;
tty.main.c_iflag &= ~ASCEDIT;
#else
- tty.main.c_cc[VSTRT] = 255;
- tty.main.c_cc[VSTOP] = 255;
- tty.main.c_cc[VSUSP] = 255;
- tty.main.c_cc[VDSUSP] = 255;
+ tty.main.c_cc[VSTRT] = CDISABLE;
+ tty.main.c_cc[VSTOP] = CDISABLE;
+ tty.main.c_cc[VSUSP] = CDISABLE;
+ tty.main.c_cc[VDSUSP] = CDISABLE;
#endif /* IBMR2AIX */
if (flow_control)
{
if (c >= 0)
{
struct input_event e;
+ EVENT_INIT (e);
+
e.kind = ASCII_KEYSTROKE_EVENT;
XSETINT (e.code, c);
e.frame_or_window = selected_frame;
#else /* not BSD4_1 */
signal (SIGALRM, SIG_IGN);
#endif /* not BSD4_1 */
+ SIGNAL_THREAD_CHECK (SIGALRM);
if (read_alarm_should_throw)
longjmp (read_alarm_throw, 1);
}
/* Read keyboard input into the standard buffer,
waiting for at least one character. */
-/* Make all keyboard buffers much bigger when using a window system. */
-#ifdef HAVE_WINDOW_SYSTEM
-#define BUFFER_SIZE_FACTOR 16
-#else
-#define BUFFER_SIZE_FACTOR 1
-#endif
-
void
read_input_waiting ()
{
- struct input_event e;
int nread, i;
extern int quit_char;
if (read_socket_hook)
{
- struct input_event buf[256];
+ struct input_event hold_quit;
+
+ EVENT_INIT (hold_quit);
+ hold_quit.kind = NO_EVENT;
read_alarm_should_throw = 0;
if (! setjmp (read_alarm_throw))
- nread = (*read_socket_hook) (0, buf, 256, 1);
+ nread = (*read_socket_hook) (0, 1, &hold_quit);
else
nread = -1;
- /* Scan the chars for C-g and store them in kbd_buffer. */
- for (i = 0; i < nread; i++)
- {
- kbd_buffer_store_event (&buf[i]);
- /* Don't look at input that follows a C-g too closely.
- This reduces lossage due to autorepeat on C-g. */
- if (buf[i].kind == ASCII_KEYSTROKE_EVENT
- && buf[i].code == quit_char)
- break;
- }
+ if (hold_quit.kind != NO_EVENT)
+ kbd_buffer_store_event (&hold_quit);
}
else
{
+ struct input_event e;
char buf[3];
nread = read (fileno (stdin), buf, 1);
+ EVENT_INIT (e);
/* Scan the chars for C-g and store them in kbd_buffer. */
e.kind = ASCII_KEYSTROKE_EVENT;
struct sigaction new_action, old_action;
sigemptyset (&new_action.sa_mask);
new_action.sa_handler = action;
-#if defined (SA_RESTART) && ! defined (BROKEN_SA_RESTART)
+#if defined (SA_RESTART) && ! defined (BROKEN_SA_RESTART) && !defined(SYNC_INPUT)
/* Emacs mostly works better with restartable system services. If this
flag exists, we probably want to turn it on here.
However, on some systems this resets the timeout of `select'
which means that `select' never finishes if it keeps getting signals.
BROKEN_SA_RESTART is defined on those systems. */
+ /* It's not clear why the comment above says "mostly works better". --Stef
+ When SYNC_INPUT is set, we don't want SA_RESTART because we need to poll
+ for pending input so we need long-running syscalls to be interrupted
+ after a signal that sets the interrupt_input_pending flag. */
new_action.sa_flags = SA_RESTART;
#else
new_action.sa_flags = 0;
#endif /* POSIX_SIGNALS */
\f
-#if !defined HAVE_STRSIGNAL && !defined SYS_SIGLIST_DECLARED
+#if !defined HAVE_STRSIGNAL && !HAVE_DECL_SYS_SIGLIST
static char *my_sys_siglist[NSIG];
# ifdef sys_siglist
# undef sys_siglist
sigfillset (&full_mask);
#endif
-#if !defined HAVE_STRSIGNAL && !defined SYS_SIGLIST_DECLARED
+#if !defined HAVE_STRSIGNAL && !HAVE_DECL_SYS_SIGLIST
if (! initialized)
{
# ifdef SIGABRT
sys_siglist[SIGXFSZ] = "File size limit exceeded";
# endif
}
-#endif /* !defined HAVE_STRSIGNAL && !defined SYS_SIGLIST_DECLARED */
+#endif /* !defined HAVE_STRSIGNAL && !defined HAVE_DECL_SYS_SIGLIST */
}
\f
#ifndef HAVE_RANDOM
#endif
while ((rtnval = open (path, oflag, mode)) == -1
- && (errno == EINTR));
+ && (errno == EINTR))
+ QUIT;
return (rtnval);
}
register int rtnval;
while ((rtnval = read (fildes, buf, nbyte)) == -1
- && (errno == EINTR));
+ && (errno == EINTR))
+ QUIT;
return (rtnval);
}
if (rtnval == -1)
{
if (errno == EINTR)
- continue;
+ {
+#ifdef SYNC_INPUT
+ /* I originally used `QUIT' but that might causes files to
+ be truncated if you hit C-g in the middle of it. --Stef */
+ if (interrupt_input_pending)
+ handle_async_input ();
+#endif
+ continue;
+ }
else
return (bytes_written ? bytes_written : -1);
}
wait_for_termination (cpid);
}
- if (synch_process_death != 0 || synch_process_retcode != 0)
+ if (synch_process_death != 0 || synch_process_retcode != 0
+ || synch_process_termsig != 0)
{
errno = EIO; /* We don't know why, but */
return -1; /* /bin/mkdir failed */
wait_for_termination (cpid);
}
- if (synch_process_death != 0 || synch_process_retcode != 0)
+ if (synch_process_death != 0 || synch_process_retcode != 0
+ || synch_process_termsig != 0)
{
errno = EIO; /* We don't know why, but */
return -1; /* /bin/rmdir failed */
}
#endif /* HAVE_STRSIGNAL */
+/* arch-tag: edb43589-4e09-4544-b325-978b5b121dcf
+ (do not change this comment) */