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:
ligd
2021-10-20 12:25:30 +08:00
committed by liguiding1
parent 89289e6014
commit 1952a1cf95
+9
View File
@@ -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