|
|
1.1 ! root 1: #include <stdio.h> ! 2: #include <errno.h> ! 3: #include <sys/types.h> ! 4: #include <sys/ioctl.h> ! 5: #include <signal.h> ! 6: #include <dkmgr.h> ! 7: #include "defs.h" ! 8: ! 9: #define DEBUG if (FALSE) ! 10: ! 11: /* imported */ ! 12: extern int errno; ! 13: extern int dkp_ld; ! 14: extern char *sname(); ! 15: extern char *strcpy(); ! 16: extern unsigned int alarm(); ! 17: ! 18: /* global */ ! 19: int rxpid; ! 20: ! 21: /* come here if the "rx" times out */ ! 22: static timeout() ! 23: { ! 24: kill (rxpid, SIGKILL); ! 25: } ! 26: ! 27: /* call up a daeon on a particular machine */ ! 28: calldaemon (sysname, daemonname) ! 29: char *sysname; ! 30: char *daemonname; ! 31: { ! 32: char *name; ! 33: int fd, i; ! 34: ! 35: name = sname(sysname, daemonname); ! 36: fd = tdkdial(name, 0); ! 37: if (fd >= 0) { ! 38: if (dkproto(fd, dkp_ld) < 0) { ! 39: (void)close(fd); ! 40: fd = -1; ! 41: } ! 42: } ! 43: if (fd < 0) { ! 44: /* try starting the daemon */ ! 45: switch (rxpid = fork()) { ! 46: case -1: ! 47: break; ! 48: case 0: ! 49: for (i = 0; i < 20; i++) ! 50: close (i); ! 51: execlp("rx", "rx", sysname, "/usr/jerq/lib/sysmond", 0); ! 52: _exit (0); ! 53: default: ! 54: (void)signal (SIGALRM, timeout); ! 55: alarm (60); ! 56: while ((i = wait(&i)) != rxpid && i >= 0) ! 57: ; ! 58: alarm (0); ! 59: (void)signal (SIGALRM, SIG_IGN); ! 60: name = sname(sysname, daemonname); ! 61: fd = tdkdial(name, 0); ! 62: if (fd >= 0) { ! 63: if (dkproto(fd, dkp_ld) < 0) { ! 64: (void)close (fd); ! 65: fd = -1; ! 66: } ! 67: } ! 68: break; ! 69: } ! 70: } ! 71: return (fd); ! 72: } ! 73:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.