_modbus_tcp_select goes into infinite loop on EINTR

52 views
Skip to first unread message

Krishnaraj R Bhat

unread,
Jul 4, 2017, 12:27:33 PM7/4/17
to libmodbus
Hi All,

I have a scenario to call modbus_receive() in a loop, basically indefinitely listen for commands in a separate thread. Since this was a blocking call, the deinit routine would wait indefinitely for the thread to close. The place where it blocks is _modbus_tcp_select() where select() is called. Select() will return EINTR when a signal is encountered. But when select() fails with EINTR, select() is called indefinitely in a loop (https://github.com/stephane/libmodbus/blob/master/src/modbus-tcp.c#L711)

Why is this done this way?

-- Thanks

Stéphane Raimbault

unread,
Jul 4, 2017, 6:02:23 PM7/4/17
to libm...@googlegroups.com
It's usual to receive EINTR in select() calls on Linux. I don't know why the system emits them (if someone knows I would be happy to learn more about that), sometimes it's just once a day sometimes never but they must be ignored, all others signals exit the loop.

--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes "libmodbus".
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse libmodbus+unsubscribe@googlegroups.com.
Pour obtenir davantage d'options, consultez la page https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages