How poll deal with closed pipe

Asked
Active3 hr before
Viewed126 times

5 Answers

closed
90%

When a pipe close , what status poll will set for the pipe's file descriptor?,I try the code below, After child process close all file descriptor , the poll just think all file descriptor can read! Is that right? Or just I make some mistake in this code?,I think after the child process close all write file descriptor , the poll will set the revents POLLHUP .But it just set it POLLIN !,When the writing end of the pipe is closed, the reading end will appear "readable" to select() and poll() - this is because a read() will not block.

You should always compile your programs with the -Wall option (at least). That would have told you about this problem:

if (fd[i].revents = POLLIN)
load more v
88%

For details of in-depth Linux/UNIX system programming training courses that I teach, look here. , HTML rendering created 2021-08-27 by Michael Kerrisk, author of The Linux Programming Interface, maintainer of the Linux man-pages project.

POLL(2) Linux Programmer 's Manual                POLL(2)
load more v
72%

/dev/poll behaviour is very close to the standard poll() object.,Remove a registered file descriptor from the epoll object.,The module defines the following:,File objects on Windows are not acceptable, but sockets are. On Windows, the underlying select() function is provided by the WinSock library, and does not handle file descriptors that don’t originate from WinSock.

load more v
65%

The close() API closes any open socket descriptors.,The send() API echoes the data back to the client. ,close()--Close File or Socket Descriptor API,The following calls are used in the example:

0
75%

If one end of the pipe is closed, 0 is returned, indicating the end of the file. , If one end of the pipe is closed, 0 is returned, indicating the end of the file. ,If the write side of the FIFO has closed, read(2) returns 0 to indicate the end of the file. , If the write side of the FIFO has closed, read(2) returns 0 to indicate the end of the file.


	/usr/sbin / mknod xxx pls - l xxx
	prw - r--r--1 guest other 0 Aug 26 10: 55 xxx
	echoput > hello.world > xxx & put > [1] 8733
	cat xxx
	hello world
	   [1] + Done
	rm xxx

Other "closed-undefined" queries related to "How poll deal with closed pipe"