Add O_NONBLOCK support to pipes.

This commit is contained in:
Jonas 'Sortie' Termansen 2013-03-31 17:26:03 +02:00
parent c514dda0b2
commit 514fab5359
1 changed files with 4 additions and 0 deletions

View File

@ -149,6 +149,8 @@ ssize_t PipeChannel::read(ioctx_t* ctx, uint8_t* buf, size_t count)
if ( !lock.IsAcquired() ) { errno = EINTR; return -1; } if ( !lock.IsAcquired() ) { errno = EINTR; return -1; }
while ( anywriting && !bufferused ) while ( anywriting && !bufferused )
{ {
if ( ctx->dflags & O_NONBLOCK )
return errno = EWOULDBLOCK, -1;
if ( !kthread_cond_wait_signal(&readcond, &pipelock) ) if ( !kthread_cond_wait_signal(&readcond, &pipelock) )
{ {
errno = EINTR; errno = EINTR;
@ -175,6 +177,8 @@ ssize_t PipeChannel::write(ioctx_t* ctx, const uint8_t* buf, size_t count)
if ( !lock.IsAcquired() ) { errno = EINTR; return -1; } if ( !lock.IsAcquired() ) { errno = EINTR; return -1; }
while ( anyreading && bufferused == buffersize ) while ( anyreading && bufferused == buffersize )
{ {
if ( ctx->dflags & O_NONBLOCK )
return errno = EWOULDBLOCK, -1;
if ( !kthread_cond_wait_signal(&writecond, &pipelock) ) if ( !kthread_cond_wait_signal(&writecond, &pipelock) )
{ {
errno = EINTR; errno = EINTR;