1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-13 11:42:21 +00:00

slowread(): Turn off O_NONBLOCK for stdin if it is on (#471)

This change turns off O_NONBLOCK for stdin if a previously ran
program left it on so that interactive programs that expect it
to be off work properly.

src/cmd/ksh93/sh/io.c: slowread():
- Turn off O_NONBLOCK for stdin if it is on.

Fixes: https://github.com/ksh93/ksh/issues/469
This commit is contained in:
atheik 2022-02-23 05:39:15 +02:00 committed by Martijn Dekker
parent e87dbebebd
commit 2e5fd4d4c1
4 changed files with 17 additions and 2 deletions

View file

@ -18,6 +18,7 @@ ksh 93u+m general copyright notice
# Johnothan King <johnothanking@protonmail.com> #
# hyenias <58673227+hyenias@users.noreply.github.com> #
# Anuradha Weeraman <anuradha@weeraman.com> #
# atheik <atteh.mailbox@gmail.com> #
# Chase <nicetrynsa@protonmail.ch> #
# Finnbarr P. Murphy <fpm@hotmail.com> #
# Govind Kamat <govind_kamat@yahoo.com> #

6
NEWS
View file

@ -3,6 +3,12 @@ For full details, see the git log at: https://github.com/ksh93/ksh/tree/1.0
Any uppercase BUG_* names are modernish shell bug IDs.
2022-08-23:
- When reading input from the keyboard, ksh now turns off nonblocking I/O
mode for standard input if a previously ran program left it on, so that
interactive programs that expect it to be off work properly.
2022-02-18:
- Fixed a regression introduced on 2021-04-11 that caused the += operator in

View file

@ -21,7 +21,7 @@
#define SH_RELEASE_FORK "93u+m" /* only change if you develop a new ksh93 fork */
#define SH_RELEASE_SVER "1.0.0-beta.2" /* semantic version number: https://semver.org */
#define SH_RELEASE_DATE "2022-02-18" /* must be in this format for $((.sh.version)) */
#define SH_RELEASE_DATE "2022-02-23" /* must be in this format for $((.sh.version)) */
#define SH_RELEASE_CPYR "(c) 2020-2022 Contributors to ksh " SH_RELEASE_FORK
/* Scripts sometimes field-split ${.sh.version}, so don't change amount of whitespace. */

View file

@ -1944,7 +1944,7 @@ static ssize_t piperead(Sfio_t *iop,void *buff,register size_t size,Sfdisc_t *ha
static ssize_t slowread(Sfio_t *iop,void *buff,register size_t size,Sfdisc_t *handle)
{
int (*readf)(void*, int, char*, int, int);
int reedit=0, rsize;
int reedit=0, rsize, n, fno;
#if SHOPT_HISTEXPAND
char *xp=0;
#endif /* SHOPT_HISTEXPAND */
@ -1969,6 +1969,14 @@ static ssize_t slowread(Sfio_t *iop,void *buff,register size_t size,Sfdisc_t *ha
errno = EINTR;
return(-1);
}
fno = sffileno(iop);
#ifdef O_NONBLOCK
if((n=fcntl(fno,F_GETFL,0))!=-1 && n&O_NONBLOCK)
{
n &= ~O_NONBLOCK;
fcntl(fno, F_SETFL, n);
}
#endif /* O_NONBLOCK */
while(1)
{
if(io_prompt(iop,sh.nextprompt)<0 && errno==EIO)