> Many system calls will report the EINTR error code if a signal occurred while the system call was in progress. No error actually occurred, it's just reported that way because the system isn't able to resume the system call automatically. This coding pattern simply retries the system call when this happens, to ignore the interrupt.
> For instance, this might happen if the program makes use of alarm() to run some code asynchronously when a timer runs out. If the timeout occurs while the program is calling write(), we just want to retry the system call (aka read/write, etc).
It's perfectly valid behaviour, and the solution is to retry in that case.
Setting the SA_RESTART flag using sigaction[1], which Postgres does, makes it invalid behaviour. Even according to Apple's (confusingly worded) documentation[2].
> For instance, this might happen if the program makes use of alarm() to run some code asynchronously when a timer runs out. If the timeout occurs while the program is calling write(), we just want to retry the system call (aka read/write, etc).
It's perfectly valid behaviour, and the solution is to retry in that case.