Disable attempts to handle EINTR and non-blocking I/O by default. It is
confusing to other programs and unexpected behavior. Reported by Ingo Schwarze. This behavior is now controlled with EL_SAFEREAD.
This commit is contained in:
parent
c191adf61d
commit
da69b70b9f
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: editline.3,v 1.99 2018/11/18 17:09:39 christos Exp $
|
||||
.\" $NetBSD: editline.3,v 1.100 2021/08/15 10:08:41 christos Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1997-2014 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
|
@ -26,7 +26,7 @@
|
|||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd November 9, 2018
|
||||
.Dd August 15, 2021
|
||||
.Dt EDITLINE 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
@ -507,6 +507,16 @@ unbuffered mode is disabled (the default).
|
|||
In unbuffered mode,
|
||||
.Fn el_gets
|
||||
will return immediately after processing a single character.
|
||||
.It Dv EL_SAFEREAD , Fa "int flag"
|
||||
If
|
||||
.Fa flag
|
||||
argument non zero, then
|
||||
.Nm editline
|
||||
attempts to recover from read errors, ignoring the first interrrupted
|
||||
error, and trying to reset the input file descriptor to reset non-blocking I/O.
|
||||
This is disabled by default, and desirable only when
|
||||
.Nm editline
|
||||
is used in shell-like applications.
|
||||
.It Dv EL_GETCFN , Fa "el_rfunc_t f"
|
||||
Whenever reading a character, use the function
|
||||
.Bd -ragged -offset indent -compact
|
||||
|
@ -634,6 +644,10 @@ call.
|
|||
Set
|
||||
.Fa c
|
||||
to non-zero if unbuffered mode is enabled.
|
||||
.It Dv EL_SAFEREAD , Fa "int *c"
|
||||
Set
|
||||
.Fa c
|
||||
to non-zero if safe read is set.
|
||||
.It Dv EL_GETFP , Fa "int fd", Fa "FILE **fp"
|
||||
Set
|
||||
.Fa fp
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: el.c,v 1.99 2019/07/23 10:18:52 christos Exp $ */
|
||||
/* $NetBSD: el.c,v 1.100 2021/08/15 10:08:41 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -37,7 +37,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)el.c 8.2 (Berkeley) 1/3/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: el.c,v 1.99 2019/07/23 10:18:52 christos Exp $");
|
||||
__RCSID("$NetBSD: el.c,v 1.100 2021/08/15 10:08:41 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
|
@ -300,6 +300,14 @@ el_wset(EditLine *el, int op, ...)
|
|||
break;
|
||||
}
|
||||
|
||||
case EL_SAFEREAD:
|
||||
if (va_arg(ap, int))
|
||||
el->el_flags |= FIXIO;
|
||||
else
|
||||
el->el_flags &= ~FIXIO;
|
||||
rv = 0;
|
||||
break;
|
||||
|
||||
case EL_EDITMODE:
|
||||
if (va_arg(ap, int))
|
||||
el->el_flags &= ~EDIT_DISABLED;
|
||||
|
@ -429,6 +437,11 @@ el_wget(EditLine *el, int op, ...)
|
|||
rv = 0;
|
||||
break;
|
||||
|
||||
case EL_SAFEREAD:
|
||||
*va_arg(ap, int *) = (el->el_flags & FIXIO);
|
||||
rv = 0;
|
||||
break;
|
||||
|
||||
case EL_TERMINAL:
|
||||
terminal_get(el, va_arg(ap, const char **));
|
||||
rv = 0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: el.h,v 1.45 2019/07/23 10:18:52 christos Exp $ */
|
||||
/* $NetBSD: el.h,v 1.46 2021/08/15 10:08:41 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -51,12 +51,13 @@
|
|||
|
||||
#define EL_BUFSIZ ((size_t)1024) /* Maximum line size */
|
||||
|
||||
#define HANDLE_SIGNALS 0x01
|
||||
#define NO_TTY 0x02
|
||||
#define EDIT_DISABLED 0x04
|
||||
#define UNBUFFERED 0x08
|
||||
#define NARROW_HISTORY 0x40
|
||||
#define NO_RESET 0x80
|
||||
#define HANDLE_SIGNALS 0x001
|
||||
#define NO_TTY 0x002
|
||||
#define EDIT_DISABLED 0x004
|
||||
#define UNBUFFERED 0x008
|
||||
#define NARROW_HISTORY 0x040
|
||||
#define NO_RESET 0x080
|
||||
#define FIXIO 0x100
|
||||
|
||||
typedef unsigned char el_action_t; /* Index to command array */
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: eln.c,v 1.35 2019/04/26 16:56:57 christos Exp $ */
|
||||
/* $NetBSD: eln.c,v 1.36 2021/08/15 10:08:41 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
|
@ -27,7 +27,7 @@
|
|||
*/
|
||||
#include "config.h"
|
||||
#if !defined(lint) && !defined(SCCSID)
|
||||
__RCSID("$NetBSD: eln.c,v 1.35 2019/04/26 16:56:57 christos Exp $");
|
||||
__RCSID("$NetBSD: eln.c,v 1.36 2021/08/15 10:08:41 christos Exp $");
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
#include <errno.h>
|
||||
|
@ -153,6 +153,7 @@ el_set(EditLine *el, int op, ...)
|
|||
|
||||
case EL_SIGNAL: /* int */
|
||||
case EL_EDITMODE:
|
||||
case EL_SAFEREAD:
|
||||
case EL_UNBUFFERED:
|
||||
case EL_PREP_TERM:
|
||||
ret = el_wset(el, op, va_arg(ap, int));
|
||||
|
@ -315,6 +316,7 @@ el_get(EditLine *el, int op, ...)
|
|||
|
||||
case EL_SIGNAL: /* int * */
|
||||
case EL_EDITMODE:
|
||||
case EL_SAFEREAD:
|
||||
case EL_UNBUFFERED:
|
||||
case EL_PREP_TERM:
|
||||
ret = el_wget(el, op, va_arg(ap, int *));
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: histedit.h,v 1.57 2017/09/01 10:19:10 christos Exp $ */
|
||||
/* $NetBSD: histedit.h,v 1.58 2021/08/15 10:08:41 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -157,6 +157,7 @@ unsigned char _el_fn_complete(EditLine *, int);
|
|||
#define EL_RPROMPT_ESC 22 /* , prompt_func, Char); set/get */
|
||||
#define EL_RESIZE 23 /* , el_zfunc_t, void *); set */
|
||||
#define EL_ALIAS_TEXT 24 /* , el_afunc_t, void *); set */
|
||||
#define EL_SAFEREAD 25 /* , int); set/get */
|
||||
|
||||
#define EL_BUILTIN_GETCFN (NULL)
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: read.c,v 1.106 2019/07/23 10:18:52 christos Exp $ */
|
||||
/* $NetBSD: read.c,v 1.107 2021/08/15 10:08:41 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -37,7 +37,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)read.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: read.c,v 1.106 2019/07/23 10:18:52 christos Exp $");
|
||||
__RCSID("$NetBSD: read.c,v 1.107 2021/08/15 10:08:41 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
|
@ -277,7 +277,7 @@ static int
|
|||
read_char(EditLine *el, wchar_t *cp)
|
||||
{
|
||||
ssize_t num_read;
|
||||
int tried = 0;
|
||||
int tried = (el->el_flags & FIXIO) == 0;
|
||||
char cbuf[MB_LEN_MAX];
|
||||
size_t cbp = 0;
|
||||
int save_errno = errno;
|
||||
|
|
Loading…
Reference in New Issue