mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 15:58:59 +08:00
pipe: pipe close should notify block writting, and write will return -EPIPE
Change-Id: I1d1d1be618b6cc423e14f94c7028c3406e7de5a6 Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
@@ -346,6 +346,10 @@ int pipecommon_close(FAR struct file *filep)
|
||||
/* Inform poll writers that other end closed. */
|
||||
|
||||
pipecommon_pollnotify(dev, POLLERR);
|
||||
while (nxsem_get_value(&dev->d_wrsem, &sval) == 0 && sval < 0)
|
||||
{
|
||||
nxsem_post(&dev->d_wrsem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -654,6 +658,11 @@ ssize_t pipecommon_write(FAR struct file *filep, FAR const char *buffer,
|
||||
ret = nxsem_wait(&dev->d_wrsem);
|
||||
sched_unlock();
|
||||
|
||||
if (dev->d_nreaders <= 0)
|
||||
{
|
||||
ret = -EPIPE;
|
||||
}
|
||||
|
||||
if (ret < 0 || (ret = nxsem_wait(&dev->d_bfsem)) < 0)
|
||||
{
|
||||
/* Either call nxsem_wait may fail because a signal was
|
||||
|
||||
Reference in New Issue
Block a user