Submit behavior to Broken pipe

When writing a simple server-client application, this question came to my mind. When someone tries to write a broken pipe, SIGPIPE is generated. Say I'm processing a signal in my code.

Now what error causes a write call - EPIPE or EINTR (since it was interrupted by a signal). I tried with a sample program, and I seem to get EPIPE always. Is this a guaranteed behavior or can it be any of two error values?

+3
source share
3 answers

POSIX says that EPIPE should be returned and SIGPIPE sent:

  • write() s pwrite() s FIFO, - , .
  • () s , .

POSIX

+2

write(2) -1 , , errno(3).

EPIPE, , . , signal(7).

+1

, " " (EINTR) Unix System V, , ( ) . do ... while (ret==-1 && errno==EINTR); . POSIX - , ( "BSD" ) , , GNU/Linux, BSD . BSD, sigaction .

, EINTR SIGPIPE, .

0

Source: https://habr.com/ru/post/1753203/


All Articles