Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: Notesfiles $Revision: 1.6.2.16 $; site mirror.UUCP Path: utzoo!watmath!clyde!burl!ulysses!gamma!epsilon!zeta!sabre!bellcore!decvax!cca!mirror!rs From: rs@mirror.UUCP Newsgroups: net.unix-wizards Subject: a small cpu hog Message-ID: <13400005@mirror.UUCP> Date: Mon, 6-May-85 16:38:00 EDT Article-I.D.: mirror.13400005 Posted: Mon May 6 16:38:00 1985 Date-Received: Fri, 10-May-85 01:39:51 EDT Lines: 71 Nf-ID: #N:mirror:13400005:000:1573 Nf-From: mirror!rs May 6 16:38:00 1985 What am I doing wrong? I have a little reminder that I want to be able to set -- sort of like leave. I want it small and unobtrusive, and I want to be able to say "alarm 10 'ten minutes are up'" I wrote the obvious program (see below), but it ends up hogging all available CPU time. If I take out the fork() call (#ifdef CPU_HOG) it doesn't take up all the time? What's going on? This only happens on BSD4.2; on Sys5, everything is ok. Why am I taking up all the cycles? #include #include /* Linked in later. */ #ifndef lint exit(X) { _exit(X); } #endif lint /* Sure-fire guaranteed file descriptors. */ #define STDIN 0 #define STDOUT 1 #define STDERR 2 /* Global variables. */ static char Usage[] = "usage: alarm delay 'message...'\n"; static char Buzzer[] = "\007\n\r"; main(ac, av) int ac; register char *av[]; { register int Temp; /* Parse JCL. */ if (ac < 3 || (Temp = atoi(av[1])) <= 0) { (void)write(STDERR, Usage, sizeof(Usage)); return(1); } (void)close(STDIN); (void)close(STDOUT); #ifdef CPU_HOG if (fork() == 0) #endif CPU_HOG { av += 2; /* Now I lay me down to sleep... */ (void)signal(SIGINT, SIG_IGN); (void)sleep((unsigned)Temp * 60); (void)write(STDERR, Buzzer, sizeof(Buzzer)); (void)write(STDERR, *av, strlen(*av)); (void)write(STDERR, Buzzer, sizeof(Buzzer)); } return(0); } thanks. -------- Rich $alz Mirror Systems 2067 Massachusetts Ave. Cambridge, MA 02150 617/661-0777 {decvax!genrad!mit-eddie, ihnp4!inmet, wjh12} !mirror!rs