ioctlsocket( fd, FIONBIO, &i_dummy );
}
#else
- fcntl( fd, F_SETFL, O_NONBLOCK );
+ fcntl( fd, F_SETFD, FD_CLOEXEC );
+ {
+ int i_val = fcntl( fd, F_GETFL );
+ fcntl( fd, F_SETFL,
+ O_NONBLOCK | (i_val != -1) ? i_val : 0 );
+ }
+
if( fd >= FD_SETSIZE )
{
net_Close( fd );