mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +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:
parent
e87dbebebd
commit
2e5fd4d4c1
4 changed files with 17 additions and 2 deletions
|
|
@ -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. */
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue