I use svscan and supervise to oversee a number of processes on my company's
email servers, including a daemon that I authored. To get a little
technical, this program uses select() to listen to two sockets, one an
internet socket that is connected to a remote database, the other a unix
socket used to collect queries from local programs to send to that
database. Recently I discovered that this program was maxing out the CPU!
I started looking for bugs in the code that could be causing this, but
didn't find any. Since the program is "idle" more often than not, I
determined that it must be select() that is causing the overload, yet
select() was designed specifically to prevent this kind of busy waiting.
Neither socket is set to nonblocking.
Finally, yesterday as I was debugging the code for other issues, I started
it up directly, without using svscan and supervise. No CPU overload! So,
something about svscan/supervise is causing this program to go hog wild.
Would supervise be spawning the process in such a way that any sockets
created by it are nonblocking? I wouldn't think so, since supervise also
oversees tcpserver processes on these systems, none of which are CPU hogs.
Whatever the cause, is this a bug or a feature? If it's a bug, does
anybody know of a workaround?
Thanks for any help, and I apologize if this is the wrong list for this
question.
---Kris Kelley