mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
libast: sfio(3) fixes from ksh 93v- beta
These fixes were backported by OpenSUSE. Original patch: https://build.opensuse.org/package/view_file/shells/ksh/ksh93-sfio.dif
This commit is contained in:
parent
63979488e6
commit
1bd0620708
7 changed files with 46 additions and 30 deletions
|
|
@ -258,7 +258,7 @@ reg Sfio_t* f; /* stream to close */
|
|||
#endif
|
||||
{
|
||||
Sfproc_t* p;
|
||||
int pid, status;
|
||||
int status;
|
||||
|
||||
if(!(p = f->proc))
|
||||
return -1;
|
||||
|
|
@ -279,7 +279,7 @@ reg Sfio_t* f; /* stream to close */
|
|||
sigcritical(SIG_REG_EXEC|SIG_REG_PROC);
|
||||
#endif
|
||||
status = -1;
|
||||
while ((pid = waitpid(p->pid,&status,0)) == -1 && errno == EINTR)
|
||||
while (waitpid(p->pid,&status,0) == -1 && errno == EINTR)
|
||||
;
|
||||
#if _PACKAGE_ast
|
||||
status = status == -1 ?
|
||||
|
|
@ -404,13 +404,17 @@ reg int local; /* a local call */
|
|||
|
||||
if(f->mode&SF_GETR)
|
||||
{ f->mode &= ~SF_GETR;
|
||||
#if defined(MAP_TYPE) && (_ptr_bits < 64)
|
||||
if((f->bits&SF_MMAP) && (f->tiny[0] += 1) >= (4*SF_NMAP) )
|
||||
{ /* turn off mmap to avoid page faulting */
|
||||
sfsetbuf(f,(Void_t*)f->tiny,(size_t)SF_UNBOUND);
|
||||
f->tiny[0] = 0;
|
||||
#ifdef MAP_TYPE
|
||||
if(f->bits&SF_MMAP)
|
||||
{
|
||||
if (!++f->ngetr)
|
||||
f->tiny[0]++;
|
||||
if(((f->tiny[0]<<8)|f->ngetr) >= (4*SF_NMAP) )
|
||||
{ /* turn off mmap to avoid page faulting */
|
||||
sfsetbuf(f,(Void_t*)f->tiny,(size_t)SF_UNBOUND);
|
||||
f->ngetr = f->tiny[0] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if(f->getr)
|
||||
{ f->next[-1] = f->getr;
|
||||
|
|
|
|||
|
|
@ -113,7 +113,11 @@ reg int rc; /* record separator */
|
|||
|
||||
/* try reading a block of data */
|
||||
direct = 0;
|
||||
if((r = fr->endb - (next = fr->next)) <= 0)
|
||||
if(fr->rsrv && (r = -fr->rsrv->slen) > 0)
|
||||
{ fr->rsrv->slen = 0;
|
||||
next = fr->rsrv->data;
|
||||
}
|
||||
else if((r = fr->endb - (next = fr->next)) <= 0)
|
||||
{ /* amount of data remained to be read */
|
||||
if((w = n > MAX_SSIZE ? MAX_SSIZE : (ssize_t)n) < 0)
|
||||
{ if(fr->extent < 0)
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ int tm; /* time in millisecs for select/poll */
|
|||
while((np = SFPOLL(fds,m,tm)) < 0 )
|
||||
{ if(errno == eintr || errno == EAGAIN)
|
||||
errno = 0;
|
||||
else break;
|
||||
else goto report;
|
||||
}
|
||||
if(np > 0) /* poll succeeded */
|
||||
np = c;
|
||||
|
|
@ -147,14 +147,14 @@ int tm; /* time in millisecs for select/poll */
|
|||
{ f = fa[check[r]];
|
||||
|
||||
if((f->flags&SF_WRITE) && !WRREADY(f) )
|
||||
{ if(fds[m].revents&POLLOUT)
|
||||
{ if(fds[m].revents&(POLLOUT|POLLHUP|POLLERR))
|
||||
status[check[r]] |= SF_WRITE;
|
||||
}
|
||||
|
||||
if((f->flags&SF_READ) && !RDREADY(f))
|
||||
{ if((f->mode&SF_WRITE) && HASAUXFD(f))
|
||||
m += 1;
|
||||
if(fds[m].revents&POLLIN)
|
||||
if(fds[m].revents&(POLLIN|POLLHUP|POLLERR))
|
||||
status[check[r]] |= SF_READ;
|
||||
}
|
||||
}
|
||||
|
|
@ -200,7 +200,7 @@ int tm; /* time in millisecs for select/poll */
|
|||
while((np = select(m+1,&rd,&wr,NIL(fd_set*),tmp)) < 0 )
|
||||
{ if(errno == eintr)
|
||||
errno = 0;
|
||||
else break;
|
||||
else goto report;
|
||||
}
|
||||
if(np > 0)
|
||||
np = c;
|
||||
|
|
@ -227,6 +227,7 @@ int tm; /* time in millisecs for select/poll */
|
|||
}
|
||||
#endif /*_lib_select*/
|
||||
|
||||
report:
|
||||
for(r = c = 0; c < n; ++c)
|
||||
{ if(status[c] == 0)
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -254,6 +254,15 @@ size_t size; /* buffer size, -1 for default size */
|
|||
#endif
|
||||
}
|
||||
|
||||
/* set page size, this is also the desired default buffer size */
|
||||
if(_Sfpage <= 0)
|
||||
{
|
||||
#if _lib_getpagesize
|
||||
if((_Sfpage = (size_t)getpagesize()) <= 0)
|
||||
#endif
|
||||
_Sfpage = SF_PAGE;
|
||||
}
|
||||
|
||||
#if SFSETLINEMODE
|
||||
if(init)
|
||||
f->flags |= sfsetlinemode();
|
||||
|
|
@ -308,15 +317,6 @@ size_t size; /* buffer size, -1 for default size */
|
|||
(void)_sfpopen(f,-1,-1,1);
|
||||
}
|
||||
}
|
||||
|
||||
/* set page size, this is also the desired default buffer size */
|
||||
if(_Sfpage <= 0)
|
||||
{
|
||||
#if _lib_getpagesize
|
||||
if((_Sfpage = (size_t)getpagesize()) <= 0)
|
||||
#endif
|
||||
_Sfpage = SF_PAGE;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MAP_TYPE
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue