-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Tests] "write" syscall generates both SIGPIPE and EPIPE #474
Comments
@SeanTAllen, this looks as if it’s related to the signal delivery. I suspect there may be something in how the syscall handler checks for signals that is wrong here. |
Assigning myself so I don't lose track of this given it might be related to the signal handling stuff I've been looking at. |
@shaikshavali1 do you have a minimal example that demonstrates the problem? |
Test case Description:The original test case is to check that the child process is killed due to “broken pipe” or not. This test case is modified to work as a single process. In modified code, below operations are performed.
Code snippet (modified code patch):
GDB Logs:
As per the man page the write should generate SIGPIPE if signal handler is registered. But, here EPIPE is also returned from write. |
Thanks. Is the SIGPIPE received? |
@prp, Yes SIGPIPE received. |
Unassigning myself as this is now a p2. |
After analysis, I found that write system call on pipe is generating both SIGPIPE and EPIPE even though we register a sighandler for SIGPIPE. This behaviour differs from pipe documentation of linux(https://www.man7.org/linux/man-pages/man7/pipe.7.html) . Below text is from man page.
“If all file descriptors referring to the write end of a pipe have been closed, then an attempt to read(2) from the pipe will see end-of-file (read(2) will return 0). If all file descriptors referring to the read end of a pipe have been closed, then a write(2) will cause a SIGPIPE signal to be generated for the calling process. If the calling process is ignoring this signal, then write(2) fails with the error EPIPE. An application that uses pipe(2) and fork(2) should use suitable close(2) calls to close unnecessary duplicate file descriptors; this ensures that end-of-file and SIGPIPE/EPIPE are delivered when appropriate.”
The text was updated successfully, but these errors were encountered: