On 02/15/16 20:27, Todd C. Miller wrote: > On Mon, 15 Feb 2016 19:22:59 +0300, Alexei Malinin wrote: > >> Please tell me can fprintf() set errno to EINTR? > Yes, it is possible but see below. > >> I have not found assignments such as "errno=EINTR" in libc sources >> (src/lib/libc/stdio, amd64 OpenBSD-5.6 ) but I'm not sure. >> >> fprintf()'s man page does not say anything about errno but POSIX.1 says, >> "If an output error was encountered, these functions shall return a >> negative value and set /errno/ to indicate the error." > If a signal handler is installed without the SA_RESTART flag set, > the write(2) system call may fail with errno set to EINTR. The > fprintf(3) function uses write(2) (deep) under the covers to write > to a file or terminal. The signal(3) function always sets the > SA_RESTART flag unless siginterrupt(3) has been used to make system > calls interruptible. If the sigaction(2) system call is used, > SA_RESTART must be explicitly set in sa_flags.
Thank you for the explanation, Todd. But can fprintf() set errno to EINTR if a program has no signal handlers (i. e. there are default handlers for all signals)? For example what will happen with fprintf() in a program with default signal dispositions if the program's window size changes (SIGWINCH)? -- Alexei