freebsd-ports/www/spreadlogd/files/patch-spreadlogd.c
Jean-Yves Lefort 0ceee22139 Add spreadlogd.
If you kill -HUP or kill the spreadlogd process, it will not actually process
the signal until after it has received its next message from Spread. You can
move you log files to new names and then kill -HUP and it will reopen the log
files. This is useful for seamless log rotation without losing any messages.

Spread is really cool. It is a poweful group communication toolkit developed
at the Center for Networking and Distributed Systems at the Johns Hopkins
University (http://www.spread.org/ and http://www.cnds.jhu.edu/, respectively).

WWW: http://www.lethargy.org/mod_log_spread/

PR:		ports/80877
Submitted by:	Meno Abels <meno.abels@adviser.com>
2005-05-14 11:12:15 +00:00

48 lines
1.2 KiB
C

--- spreadlogd.c.orig Tue Jul 3 22:09:48 2001
+++ spreadlogd.c Sat May 14 12:47:05 2005
@@ -114,9 +114,15 @@
}
}
void daemonize(void) {
+ FILE *fd;
+ char buf[16];
if(fork()!=0) exit(0);
setsid();
if(fork()!=0) exit(0);
+ fd = fopen("/var/run/spreadlogd.pid", "w");
+ sprintf(buf, "%d", getpid());
+ fputs(buf, fd);
+ fclose(fd);
}
int getnropen(void) {
struct rlimit rlim;
@@ -127,9 +133,6 @@
}
int main(int argc, char **argv) {
-#ifdef SPREAD_VERSION
- int mver, miver, pver;
-#endif
char *configfile = default_configfile;
char *message;
int getoption, debug = 0;
@@ -137,7 +140,8 @@
sigset_t ourmask;
nr_open = getnropen();
- fdsetsize = getdtablesize();
+ fdsetsize = 512; /* getdtablesize(); ugly fix for freebsd but the select fdset
+ is not as big as dtablesize returns so we receive some cores MENO */
fds = (SpreadConfiguration **)malloc(sizeof(SpreadConfiguration *)*
fdsetsize);
memset(fds, 0, sizeof(SpreadConfiguration *)*fdsetsize);
@@ -182,7 +186,7 @@
buffsize);
}
- if(!debug) daemonize();
+ if(!debug) { daemonize(); }
/* Set up HUP signal */
signalaction.sa_handler = sig_handler;