[imapfilter-devel] Problem with daemon mode
Lefteris Chatzibarbas
lefcha at hellug.gr
Mon Jan 26 23:55:25 EET 2004
On Mon, Jan 26, 2004 at 03:35:00PM +0500, Igor Klingen wrote:
> 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.
I made some improvements/corrections to the "to daemon mode" code. You
shouldn't have this problem anymore. Check out from CVS or get this
snapshot:
http://imapfilter.hellug.gr/temp/imapfilter-20040126.tar.gz
Thanks for bringing this up.
More information about the Imapfilter-devel
mailing list