Hello,
I am developing a linux-based modbus-tcp slace/device using libmodbus.
To to quit my application while modbus_receive() is running, I call shutdown(socket, SHUT_RDWR). to cancel this call.
But in the file modbus-tcp.c the following code can be found in _modbus_tcp_select:
#####################
while ((s_rc = select(ctx->s+1, rset, NULL, NULL, tv)) == -1) {
if (errno == EINTR) {
if (ctx->debug) {
fprintf(stderr, "A non blocked signal was caught\n");
}
/* Necessary after an error */
FD_ZERO(rset);
FD_SET(ctx->s, rset);
} else {
*/
return -1;
}
...
#####################
Thats why I can not cancel modbus_receive() and only get the message "A non blocked signal was caught".
My code works fine if I disable the special handling of EINTR.
Why is EINTR handled this way?
How can I quit my application while modbus_receive() is running?
Thanks,
Sandro