/* $Id: forever.c,v 1.1 2012/10/08 16:14:50 ksb Exp $ * Sleep forever, as cheaply as possible. (ksb) * This is used as a wrapper control process when ":" is not enough. * The colon form allows a client to end the diversion with -Q, forever * doesn't let that happen. * $Compile(*): ${cc:-cc} ${cc_debug:-"-O"} -D%s -o %F %f */ #include #include #include #include #include #include #include static char rcsid[] = "$Id: forever.c,v 1.1 2012/10/08 16:14:50 ksb Exp $"; static char *progname; /* Drop our priority, just to be nice. Wait for a signal until one * of them kills us (viz. INT, KILL, FPE etc.). */ int main(int argc, char **argv) { register int c; extern int opterr; if ((char *)0 == argv[0]) { progname = "forever"; } else if ((char *)0 == (progname = strrchr(argv[0], '/'))) { progname = argv[0]; } else { ++progname; } opterr = 0; while (-1 != (c = getopt(argc, argv, "hV"))) { switch (c) { case 'V': printf("%s: %s\n", progname, rcsid); exit(EX_OK); /*NOTREACHED*/ case 'h': printf("%s: usgae [label]\n%s: usage -h\n%s: usage -V\n", progname, progname, progname); exit(EX_OK); /*NOTREACHED*/ default: /* a label of "--hush" is fine */ break; } break; } (void)setpriority(PRIO_PROCESS, 0, 20); close(0); close(1); close(2); do { pause(); } while (1); /*NOTREACHED*/ exit(EX_OK); }