recvfrom() not a thread cancellation point

Daniel Eischen deischen at freebsd.org
Fri Mar 31 20:40:27 UTC 2006


On Fri, 31 Mar 2006, Niall Douglas wrote:

> Hi,
>
> How do I receive UDP packets using recvfrom() when it would seem that
> recvfrom() is not a thread cancellation point on FreeBSD 6.0?

1) select() or poll() instead, then recvfrom().  UDP packets
   are never partial IIRC.

2) Unmask a signal in the thread doing the recvfrom(), then
   use pthread_kill() to interrupt it (don't use SA_RESTART
   for sa_flags in the signal action).

> Is there an alternative method of receiving UDP packets which is
> thread cancellable? The best I can see is using plain read() but this
> of course won't return the sender of the UDP packet.

-- 
DE



More information about the freebsd-threads mailing list