diff options
| author | Shell <[email protected]> | 2023-06-29 00:00:27 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-06-29 00:00:27 +0800 |
| commit | 0b79bea7cde71dc8db1d8ba33acd2705de64ee76 (patch) | |
| tree | 3e7f1c8e97d15ba6f87eeba9151139a4c0519ae7 /components/drivers | |
| parent | eafc77318683f5806c3b07f5e18dbcfa43073e2a (diff) | |
[components/lwp] clear ref to parent on waitpid() (#7741)
Signed-off-by: shell <[email protected]>
Diffstat (limited to 'components/drivers')
| -rw-r--r-- | components/drivers/ipc/pipe.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/components/drivers/ipc/pipe.c b/components/drivers/ipc/pipe.c index bfed214678..d1e8665963 100644 --- a/components/drivers/ipc/pipe.c +++ b/components/drivers/ipc/pipe.c @@ -7,6 +7,8 @@ * Date Author Notes * 2012-09-30 Bernard first version. * 2017-11-08 JasonJiaJie fix memory leak issue when close a pipe. + * 2023-06-28 shell return POLLHUP when writer closed its channel on poll() + * fix flag test on pipe_fops_open() */ #include <rthw.h> #include <rtdevice.h> @@ -65,12 +67,12 @@ static int pipe_fops_open(struct dfs_file *fd) rt_mutex_take(&pipe->lock, RT_WAITING_FOREVER); - if ((fd->flags & O_RDONLY) == O_RDONLY) + if ((fd->flags & O_ACCMODE) == O_RDONLY) { pipe->reader = 1; } - if ((fd->flags & O_WRONLY) == O_WRONLY) + if ((fd->flags & O_ACCMODE) == O_WRONLY) { pipe->writer = 1; } @@ -362,6 +364,10 @@ static int pipe_fops_poll(struct dfs_file *fd, rt_pollreq_t *req) { mask |= POLLIN; } + else if (pipe->writer == 0) + { + mask = POLLHUP; + } } if (mode & 2) |
