Skip to content

interrupt: check EINTR for IO operations

The definition of read() and write() mandate from their prototype that the return value and errno must be checked since the syscall can be interrupted without being processed by a signal:

../../src/misc/interrupt.c: In function 'vlc_poll_i11e_inner':
WARNING : ../../src/misc/interrupt.c:358: 9:  ignoring return value of 'read' declared with attribute 'warn_unused_result' [-Wunused-result]
  358 |         read(fd[0], &dummy, sizeof (dummy));
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/misc/interrupt.c: In function 'vlc_poll_i11e_wake':
WARNING : ../../src/misc/interrupt.c:299: 5:  ignoring return value of 'write' declared with attribute 'warn_unused_result' [-Wunused-result]
  299 |     write(fd[1], &value, sizeof (value));
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In practice, we write and read into an eventfd or a pipe descriptor, and we only read when poll() notify that a read operation will be non-blocking, so the interruption can mostly never happen in production, but it can happen when using different tools, like ones using SIGPROF for instance.

See also commit 2f2a4787.

Merge request reports