|
|
1.1 ! root 1: #include <stdio.h> ! 2: #include <sys/dkio.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: ioctl(f, DIOCNXCL, 0); ! 46: for (;;) { ! 47: n = read(f, buf, sizeof buf) ; ! 48: if (n <= 0) { ! 49: for (i=0; i < 5; i++) { ! 50: sleep(1); ! 51: n = read(f, buf, sizeof(buf)); ! 52: if (n > 0) ! 53: goto OK; ! 54: } ! 55: printf("Shutting down KMC\n"); ! 56: ioctl(f, KIOCSHUT, (char *)0); ! 57: close(f); ! 58: sleep(45); ! 59: printf("reloading KMC\n"); ! 60: system("cd /usr/dk; /etc/kmcdump >regs"); ! 61: system("/etc/kdiload"); ! 62: sleep(5); ! 63: goto restart; ! 64: } ! 65: /* ! 66: printf("dkhup: read (size %d) = ", n) ; ! 67: for (i=0; i<n; i++) ! 68: printf("%o ", buf[i]&0377) ; ! 69: printf("\n\r") ; ! 70: */ ! 71: } ! 72: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.