|
|
1.1 ! root 1: #include <stdio.h> ! 2: #include <sys/ioctl.h> ! 3: #include <signal.h> ! 4: #include <ctype.h> ! 5: ! 6: char buf[64] ; ! 7: ! 8: main(argc, argv) ! 9: char **argv ; ! 10: { ! 11: int f, i; ! 12: int n ; ! 13: int traffic = 2; ! 14: extern rdk_ld; ! 15: ! 16: ! 17: signal(SIGINT, SIG_IGN); ! 18: signal(SIGQUIT, SIG_IGN); ! 19: signal(SIGHUP, SIG_IGN); ! 20: signal(SIGTERM, SIG_IGN); ! 21: signal(SIGPIPE, SIG_IGN); ! 22: while (argc > 1) { ! 23: if (strcmp(argv[1], "-t") == 0) ! 24: ; ! 25: else if (isdigit(*argv[1])) ! 26: traffic = atoi(argv[1]); ! 27: else ! 28: printf("dkhup: argument %s ignored\n"); ! 29: argc--; ! 30: argv++; ! 31: } ! 32: if (fork()) ! 33: return(0) ; ! 34: restart: ! 35: if ((f = dkctlchan(traffic)) < 0) { ! 36: printf("dkhup: cannot open ctlr channel\n", traffic); ! 37: exit(1); ! 38: } ! 39: if (argc < 3) { ! 40: ioctl(f, DIOCHUP, 0); ! 41: ioctl(f, DIOCHUP, 0); ! 42: ioctl(f, DIOCHUP, 0); ! 43: } ! 44: OK: ! 45: for (;;) { ! 46: n = read(f, buf, sizeof buf) ; ! 47: if (n <= 0) { ! 48: for (i=0; i < 5; i++) { ! 49: sleep(1); ! 50: n = read(f, buf, sizeof(buf)); ! 51: if (n > 0) ! 52: goto OK; ! 53: } ! 54: printf("Shutting down KMC\n"); ! 55: ioctl(f, KIOCSHUT, (char *)0); ! 56: close(f); ! 57: sleep(45); ! 58: printf("reloading KMC\n"); ! 59: system("/etc/kdiload"); ! 60: sleep(5); ! 61: goto restart; ! 62: } ! 63: printf("dkhup: read (size %d) = ", n) ; ! 64: for (i=0; i<n; i++) ! 65: printf("%o ", buf[i]&0377) ; ! 66: printf("\n\r") ; ! 67: } ! 68: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.