1 --- spamass-milt/spamass-milter.cpp:1.69 Fri Sep 12 05:45:05 2003
2 +++ spamass-milt/spamass-milter.cpp Tue Oct 21 21:40:32 2003
4 main(int argc, char* argv[])
7 - const char *args = "p:fd:mr:u:D:i:b:B:";
8 + const char *args = "fd:mp:P:r:u:D:i:b:B:";
13 const char *args = "p:fd:mr:u:D:i:b:B:";
16 + char *pidfilename = NULL;
17 + FILE *pidfile = NULL;
19 openlog("spamass-milter", LOG_PID, LOG_MAIL);
21 /* Process command line options */
22 while ((c = getopt(argc, argv, args)) != -1) {
25 - sock = strdup(optarg);
31 dontmodifyspam = true;
32 smfilter.xxfi_flags &= ~(SMFIF_CHGBODY|SMFIF_CHGHDRS);
35 + sock = strdup(optarg);
38 + pidfilename = strdup(optarg);
42 reject_score = atoi(optarg);
47 - if (dofork == true) {
49 - case -1: /* Uh-oh, we have a problem forking. */
50 - fprintf(stderr, "Uh-oh, couldn't fork!\n");
55 - default: /* Parent */
59 + unlink(pidfilename);
60 + pidfile = fopen(pidfilename,"w");
63 + fprintf(stderr, "Could not open pidfile: %s\n", strerror(errno));
66 + /* leave the file open through the fork, since we don't know our pid
74 + if (daemon(0, 0) == -1)
76 + fprintf(stderr, "daemon() failed: %s\n", strerror(errno));
83 + fprintf(pidfile, "%ld\n", (long)getpid());
90 if (stat(sock,&junk) == 0) unlink(sock);
92 debug(D_ALWAYS, "spamass-milter %s starting", PACKAGE_VERSION);
94 debug(D_ALWAYS, "spamass-milter %s exiting", PACKAGE_VERSION);
96 + unlink(pidfilename);