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
|
@ -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