/*
$Id$
part of m0n0wall (http://m0n0.ch/wall)
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
/* usage: minicron interval pidfile cmd */
int main(int argc, char *argv[]) {
int interval;
FILE *pidfd;
if (argc < 4)
interval
= atoi(argv
[1]); if (interval == 0)
/* unset loads of CGI environment variables */
unsetenv("CONTENT_TYPE"); unsetenv("GATEWAY_INTERFACE");
unsetenv("REMOTE_USER"); unsetenv("REMOTE_ADDR");
unsetenv("AUTH_TYPE"); unsetenv("SCRIPT_FILENAME");
unsetenv("CONTENT_LENGTH"); unsetenv("HTTP_USER_AGENT");
unsetenv("HTTP_HOST"); unsetenv("SERVER_SOFTWARE");
unsetenv("HTTP_REFERER"); unsetenv("SERVER_PROTOCOL");
unsetenv("REQUEST_METHOD"); unsetenv("SERVER_PORT");
unsetenv("SCRIPT_NAME"); unsetenv("SERVER_NAME");
/* go into background */
if (daemon(0, 0) == -1)
/* write PID to file */
pidfd
= fopen(argv
[2], "w"); if (pidfd) {
}
while (1) {
sleep(interval);
}
}