daemontools and poll() on Mac OS X Tiger (10.4)

Malte Tancred <[email protected]> Tue, 3 May 2005 03:01:36 +0200
Newsgroups gmane.org.djb.miscellaneous
Message-ID <[email protected]>
Hi!

In the latest version of Mac OS X, version 10.4 codenamed "Tiger",  
something has changed with the poll system call.

To the best of my knowledge earlier versions provided compatibility  
macros (or functions, can't remember which) for poll() based on select 
(). This seems to have changed in Tiger (which is good I suppose :-).  
However, when installing daemontools on my laptop I noticed that the  
two supervise processes monitoring dnscache and its log took a lot of  
CPU.

I sampled one of the processes (using the sample commend line tool)  
and saw that poll() (and read()!) showed up a lot, among other calls.  
I did a similar sampling on a server running an earlier version of  
Mac OS X and the only thing that showed up was select().

I didn't investigate further, went to the daemontools source on my  
laptop, added an _exit(1) first thing in main() in trypoll.c,  
reinstalled and restarted. The CPU abuse was gone and I was happy.

As I haven't investigated the problem further I can't say what was  
going on (perhaps poll() is returning something iopause doesn't  
expect, so iopause has to loop a lot; perhaps poll() is implemented  
using read() and others, so iopause sees the "right" things, but it  
isn't really pausing).

Just so you know.

Regards,
Malte

--
Malte Tancred
Computer Programmer
Oops AB, http://oops.se/