the daemon() should be called after calling smfi_opensocket().
This would also make possible to return error in case of impossibility to create
socket, so the caller knows it failed.
this patch moves the daemonising section after opening socket.
I have tried with amavisd-milter 1.6.1 and 1.5.0, works nicely.
you can find it at test.fantomas.sk/amavisd-milter-main.c.patch
--- main.c.orig 2013-04-22 02:36:12.000000000 +0200
+++ main.c 2019-01-04 15:35:29.486854008 +0100
@@ -379,17 +379,6 @@
}
}
- /* Run in the background */
- if (daemonize) {
- if (daemon(1, 1) != -1) {
- daemonized = 1;
- } else {
- logmsg(LOG_ERR, "could not fork daemon process: %s",
- strerror(errno));
- exit(EX_OSERR);
- }
- }
-
/* Connect to milter socket */
#ifdef HAVE_SMFI_SETBACKLOG
if (mlfi_socket_backlog > 0) {
@@ -406,6 +395,17 @@
}
#endif
+ /* Run in the background */
+ if (daemonize) {
+ if (daemon(1, 1) != -1) {
+ daemonized = 1;
+ } else {
+ logmsg(LOG_ERR, "could not fork daemon process: %s",
+ strerror(errno));
+ exit(EX_OSERR);
+ }
+ }
+
/* Greetings message */
logmsg(LOG_WARNING, "starting %s %s on socket %s", progname, VERSION,
mlfi_socket);
--
Matus UHLAR - fantomas, uhlar@... ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
If Barbie is so popular, why do you have to buy her friends?
Moved from amavisd-milter-users mailing list.
From: Matus UHLAR - fantomas uhlar@fa... - 2019-01-04 14:45:07
On 04.01.19 15:29, Matus UHLAR - fantomas wrote:
this patch moves the daemonising section after opening socket. I have tried with amavisd-milter 1.6.1 and 1.5.0, works nicely.
you can find it at test.fantomas.sk/amavisd-milter-main.c.patch
-- Matus UHLAR - fantomas, uhlar@... ; http://www.fantomas.sk/ Warning: I wish NOT to receive e-mail advertising to this address. Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu. If Barbie is so popular, why do you have to buy her friends?