diff --git a/src/System.Device.Gpio/System/Device/Gpio/LibgpiodDriverEventHandler.cs b/src/System.Device.Gpio/System/Device/Gpio/LibgpiodDriverEventHandler.cs index e9a4d42e416a1c8a3ae0cd18c98c3374c9f22e1d..32d332e83d3add3b2f63011e49a85d4432c5a2f2 100644 --- a/src/System.Device.Gpio/System/Device/Gpio/LibgpiodDriverEventHandler.cs +++ b/src/System.Device.Gpio/System/Device/Gpio/LibgpiodDriverEventHandler.cs @@ -11,6 +11,8 @@ namespace System.Device.Gpio.Drivers { internal sealed class LibGpiodDriverEventHandler : IDisposable { + private const int ERROR_CODE_EINTR = 4; // Interrupted system call + private static string s_consumerName = Process.GetCurrentProcess().ProcessName; public event PinChangeEventHandler? ValueRising; @@ -55,7 +57,14 @@ namespace System.Device.Gpio.Drivers WaitEventResult waitResult = Interop.libgpiod.gpiod_line_event_wait(pinHandle, ref timeout); if (waitResult == WaitEventResult.Error) { - throw ExceptionHelper.GetIOException(ExceptionResource.EventWaitError, Marshal.GetLastWin32Error(), _pinNumber); + var errorCode = Marshal.GetLastWin32Error(); + if (errorCode == ERROR_CODE_EINTR) + { + // ignore Interrupted system call error and retry + continue; + } + + throw ExceptionHelper.GetIOException(ExceptionResource.EventWaitError, errorCode, _pinNumber); } if (waitResult == WaitEventResult.EventOccured)