Portable non GNU TEMP_FAILURE_ENTRY macro

In addition to that subject Here is a portable macro that can be used in place of TEMP_FAILURE_ENTRY, without GNU_SOURCE (took from stackoverflow):

#define CALL_RETRY(retvar, expression) do { \
    retvar = (expression); \
} while (retvar == -1 && errno == EINTR);
/* call example */
SOCKET s ;
char buf[ 4096 ] = "" ;
int retval = -1 ;
/* ... stripped socket initialisation code ... */
CALL_RETRY( br , recv( s , buf , 1024, 0 ) );

In case you receive a “interrupted system calls” signal, there is a chance that this trick may help / guide you to the answer.

#gdb #socket #linux #redhat #EINTR #recv #send