[imapfilter-devel] Problem with daemon mode

Igor Klingen iklingen at front.ru
Mon Jan 26 12:35:00 EET 2004


Hi Lefteris!

RH9, IMAPFiletr 0.9.5

I'm faced with such problem. I'm runed imapfilter in daemon mode from 
PuTTY (non root account). After start daemon, I cannot close this 
session correctly.
After add to imapfilter.c next lines:

in headers list:
#include <sys/resource.h>

the 'to-daemon' peace:
case 0:
   lockfile_create();
   corefile_disable();
   flags |= FLAG_DAEMON_MODE;

I add:
case 0:
   {
        int i;  struct rlimit file_lim;
        setsid();
        chdir("/");
        getrlimit( RLIMIT_NOFILE, &file_lim );
        for( i = 0; i < file_lim.rlim_max; i++ ) close( i );
   }
   lockfile_create();
   corefile_disable();
   flags |= FLAG_DAEMON_MODE;

After this change, session will be closed correctly. But imapfilter stop 
write to log-file :). (But worked).
May be, change manipulate with log, such that log-file open at once 
before write and close it at once after write (no flush). And disable 
all std* input/output in daemon mode.

--
Best regards
Igor Klingen




More information about the Imapfilter-devel mailing list