|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T d
Length: 1146 (0x47a) Types: TextFile Names: »daemon.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987 └─⟦this⟧ »EUUGD18/General/Gb/daemon.c«
/* * Galactic Bloodshed (Robert Chansky, smq@b) * daemon.c -- sleep for awhile, then do a turn */ #include "tweakables.h" #include "files.h" #include <stdio.h> #include <signal.h> #include <time.h> #include <sys/types.h> #include <sys/timeb.h> #include <sys/file.h> #include <sys/ioctl.h> main() { struct tm *t; long clk; int turn=0,update=0,fd2; FILE *fd; if (fork()) exit(); /* detach from shell */ sigblock(SIGHUP|SIGINT|SIGQUIT); /* ignore signal from owner logging out */ fd2 = open("/dev/tty", O_RDWR); /* disassociate from tty */ ioctl(fd2, TIOCNOTTY, 0); close(fd2); while (1) { clk = time(0); t = localtime(&clk); printf("day %d,hour %d,min %d,sec %d\n", t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec); if ( (t->tm_hour % UPDATE_TIME)==0 && update!=t->tm_hour) { update = t->tm_hour; doturn(0); /* not from shell */ fd = fopen(PROFDATAFL, "a"); clk = time(0); t = localtime(&clk); fprintf(fd,"turn %d @ day %d,hour %d,min %d,sec %d, time=%d secs\n", turn++, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, t->tm_min * 60 + t->tm_sec); fclose(fd); } else sleep(600); } }