Well, isn’t this special.
Working with a bit of code for a postfix policy filter that was originally written on Linux. Works fine there. On the other hand, I am having a bit of trouble getting it to work properly on Solaris.
Run it in full debug mode, non-daemon, spewing to my tty to look at all the gorey details in depth. Hmm, seems fine… run it in daemon mode, at any level of debug and … it’s misbehaving. Weird.
Track it down to this bit of (pseudo code)
while lines in config file
read line and parse it
if foo setting found, do whatever foo setting means.
No problem, right?
Well, one of the foo settings is daemon mode. When that setting is found, the daemonize call was made which dutifully goes off, forks a few times, closes all file descriptors, etc… and when code returns to the loop… we continue processing that config file right?
Yes! That’s correct! On Linux, of whatever flavour the original author is using, this works.
Not on Solaris. Solaris scrubs the file descriptors clean. Can’t reference anything with them.
I guess somewhere in the bowels of that version of linux, it just marks the fd pointer as not being used anymore but leaves a valid pointer in it, pointing to a chunk of file system buffer in ram and …. for the very short time after the forking and fd closing frenzy, the code can manage to grovel thru the rest of the config file which fits into one disk buffer anyways, being small.
Bonk! Bad programmer! No cookie for you!
And you! Kernel programmer! Come back, no sneaking off now. I want to have a word with you . . .