-/* $OpenBSD: cl.h,v 1.10 2016/05/27 09:18:11 martijn Exp $ */
+/* $OpenBSD: cl.h,v 1.11 2021/09/01 14:28:15 schwarze Exp $ */
/*-
* Copyright (c) 1993, 1994
* @(#)cl.h 10.19 (Berkeley) 9/24/96
*/
+extern volatile sig_atomic_t cl_sighup;
+extern volatile sig_atomic_t cl_sigint;
+extern volatile sig_atomic_t cl_sigterm;
+extern volatile sig_atomic_t cl_sigwinch;
+
typedef struct _cl_private {
CHAR_T ibuf[256]; /* Input keys. */
#define CL_RENAME_OK 0x0004 /* User wants the windows renamed. */
#define CL_SCR_EX_INIT 0x0008 /* Ex screen initialized. */
#define CL_SCR_VI_INIT 0x0010 /* Vi screen initialized. */
-#define CL_SIGHUP 0x0020 /* SIGHUP arrived. */
-#define CL_SIGINT 0x0040 /* SIGINT arrived. */
-#define CL_SIGTERM 0x0080 /* SIGTERM arrived. */
-#define CL_SIGWINCH 0x0100 /* SIGWINCH arrived. */
-#define CL_STDIN_TTY 0x0200 /* Talking to a terminal. */
+#define CL_STDIN_TTY 0x0020 /* Talking to a terminal. */
u_int32_t flags;
} CL_PRIVATE;
-/* $OpenBSD: cl_funcs.c,v 1.20 2016/05/27 09:18:11 martijn Exp $ */
+/* $OpenBSD: cl_funcs.c,v 1.21 2021/09/01 14:28:15 schwarze Exp $ */
/*-
* Copyright (c) 1993, 1994
if (cl_ssize(sp, 1, NULL, NULL, &changed))
return (1);
if (changed)
- F_SET(CLP(sp), CL_SIGWINCH);
+ cl_sigwinch = 1;
return (0);
}
-/* $OpenBSD: cl_main.c,v 1.33 2016/05/05 20:36:41 martijn Exp $ */
+/* $OpenBSD: cl_main.c,v 1.34 2021/09/01 14:28:15 schwarze Exp $ */
/*-
* Copyright (c) 1993, 1994
GS *__global_list; /* GLOBAL: List of screens. */
+volatile sig_atomic_t cl_sighup;
+volatile sig_atomic_t cl_sigint;
+volatile sig_atomic_t cl_sigterm;
+volatile sig_atomic_t cl_sigwinch;
+
static void cl_func_std(GS *);
static CL_PRIVATE *cl_init(GS *);
static GS *gs_init(void);
{
GLOBAL_CLP;
- F_SET(clp, CL_SIGHUP);
+ cl_sighup = 1;
clp->killersig = SIGHUP;
}
static void
h_int(int signo)
{
- GLOBAL_CLP;
-
- F_SET(clp, CL_SIGINT);
+ cl_sigint = 1;
}
static void
{
GLOBAL_CLP;
- F_SET(clp, CL_SIGTERM);
+ cl_sigterm = 1;
clp->killersig = SIGTERM;
}
static void
h_winch(int signo)
{
- GLOBAL_CLP;
-
- F_SET(clp, CL_SIGWINCH);
+ cl_sigwinch = 1;
}
#undef GLOBAL_CLP
clp = GCLP(gp);
+ cl_sighup = 0;
+ cl_sigint = 0;
+ cl_sigterm = 0;
+ cl_sigwinch = 0;
+
if (sp == NULL) {
if (setsig(SIGHUP, &clp->oact[INDX_HUP], h_hup) ||
setsig(SIGINT, &clp->oact[INDX_INT], h_int) ||
-/* $OpenBSD: cl_read.c,v 1.21 2016/05/27 09:18:11 martijn Exp $ */
+/* $OpenBSD: cl_read.c,v 1.22 2021/09/01 14:28:15 schwarze Exp $ */
/*-
* Copyright (c) 1993, 1994
* so that we just keep returning them until the editor dies.
*/
clp = CLP(sp);
-retest: if (LF_ISSET(EC_INTERRUPT) || F_ISSET(clp, CL_SIGINT)) {
- if (F_ISSET(clp, CL_SIGINT)) {
- F_CLR(clp, CL_SIGINT);
+retest: if (LF_ISSET(EC_INTERRUPT) || cl_sigint) {
+ if (cl_sigint) {
+ cl_sigint = 0;
evp->e_event = E_INTERRUPT;
} else
evp->e_event = E_TIMEOUT;
return (0);
}
- if (F_ISSET(clp, CL_SIGHUP | CL_SIGTERM | CL_SIGWINCH)) {
- if (F_ISSET(clp, CL_SIGHUP)) {
- evp->e_event = E_SIGHUP;
- return (0);
- }
- if (F_ISSET(clp, CL_SIGTERM)) {
- evp->e_event = E_SIGTERM;
+ if (cl_sighup) {
+ evp->e_event = E_SIGHUP;
+ return (0);
+ }
+ if (cl_sigterm) {
+ evp->e_event = E_SIGTERM;
+ return (0);
+ }
+ if (cl_sigwinch) {
+ cl_sigwinch = 0;
+ if (cl_ssize(sp, 1, &lines, &columns, &changed))
+ return (1);
+ if (changed) {
+ (void)cl_resize(sp, lines, columns);
+ evp->e_event = E_WRESIZE;
return (0);
}
- if (F_ISSET(clp, CL_SIGWINCH)) {
- F_CLR(clp, CL_SIGWINCH);
- if (cl_ssize(sp, 1, &lines, &columns, &changed))
- return (1);
- if (changed) {
- (void)cl_resize(sp, lines, columns);
- evp->e_event = E_WRESIZE;
- return (0);
- }
- /* No real change, ignore the signal. */
- }
+ /* No real change, ignore the signal. */
}
/* Set timer. */