ferrel@btni.UUCP (Roger Ferrel) (04/06/88)
Got a quick (I hope) question. Please E-mail me your answers. If there is enough interest I will post the results. My connection to uunet is via tymnet. The first part of the line in my L.sys file has the following: uunet Wk1930-0630 My problem is that last month I got charged for 3 hours of connect time during prime time which starts at either 7:30 or 8:00. (i.e. my connection ran way past 6:30 A.M.) This doubled my bill for connect charges! I'm running 4.3 BSD on VAX/750 from looking at my log it appears that uucico does not disconnet when the time goes past 6:30. What should be done to make sure that the uunet connection is disconnect shortly after the 6:30 deadline? --Roger L. Ferrel ferrel@btni.UUCP uunet!btni!ferrel
paul@devon.UUCP (Paul Sutcliffe Jr.) (04/09/88)
[ I was going to mail my reply to Roger, but I thought this might be of general interest to the net. -paul ] In article <181@btni.UUCP> ferrel@btni.UUCP (Roger Ferrel) writes: +--------- | My connection to uunet is via tymnet. The first part of the | line in my L.sys file has the following: | | uunet Wk1930-0630 | | My problem is that last month I got charged for 3 hours of | connect time during prime time which starts at either 7:30 or | 8:00. (i.e. my connection ran way past 6:30 A.M.) This doubled | my bill for connect charges! | | I'm running 4.3 BSD on VAX/750 from looking at my log it appears | that uucico does not disconnet when the time goes past 6:30. | What should be done to make sure that the uunet connection is | disconnect shortly after the 6:30 deadline? +--------- I had the same problem using Telenet's PC-Pursuit service to exchange mail and news. The problem is that every uucico that I've seen only uses the "call time" field in L.sys/Systems (e.g. Wk1930-0630) to see if it can start. My solution was to have cron execute the enclosed program each morning at 655 AM (Telenet prime time begins at 700 AM). I wrote this for my Xenix system; you're mileage may vary. Here's how it works: Invoke as "killuucp -s sysname". Killuucp will then look for a /usr/spool/uucp/LCK..sysname file. If found, it will read the PID out of it (this will be the PID of the uucico which created the LCK file). It will then try to kill that PID (this requires that your kill(2) knows how to "kill(PID, 0)" to see if the process is still running). Porting tips: check out "struct system_lock". My system stores the PID in the file as an int. I understand that some systems store it as ascii text. This will need to be correct for your system. Hope this helps. - paul ----- 8< here for killuucp.c, and watch out for .signature ----- /* * killuucp.c - kill a uucico process if it is running */ #ifndef lint static char *sccsid = "@(#)killuucp.c 1.2 (Devon) 1/7/88"; #endif #include <stdio.h> #include <sys/types.h> #include <fcntl.h> #include <signal.h> #define FALSE 0 #define TRUE ~FALSE #define ACCESS 0 #define BUFSIZE 128 #define LOCKFILE "/usr/spool/uucp/LCK..%s" #define DEBUG(a,b) if (x_flag) debug(a,b) struct system_lock { /* contents of LOCKFILE file */ int pid; /* PID of uucico process owning the LCK file */ } s_lock; char *myname; char *sysname; /* system name from -s */ main(argc, argv) int argc; char *argv[]; { int c, fd; register int x_flag = FALSE; /* debug on/off */ int s_flag = FALSE; /* TRUE if -s found */ char lock[BUFSIZE]; /* lock file name */ extern int optind; extern char *optarg; myname = argv[0]; /* this process name */ while ((c = getopt(argc, argv, "s:x")) != EOF) switch(c) { case 's': s_flag = TRUE; sysname = optarg; break; case 'x': x_flag = TRUE; break; case '?': usage(1); } if (!s_flag) usage(1); (void) sprintf(lock, LOCKFILE, sysname); DEBUG("lockfile: %s", lock); if (access(lock, ACCESS)) { DEBUG("no lockfile -- nothing to do!", ""); exit(0); } if ((fd = open(lock, O_RDONLY)) < 0) { perror(lock); exit(2); } if ((c = read(fd, &s_lock, sizeof(s_lock))) < 0) { perror(lock); exit(2); } else if (c != sizeof(s_lock)) { (void) fprintf(stderr, "%s: read error\n", lock); exit(2); } DEBUG("read(s_lock) returned: %d", c); (void) close(fd); DEBUG("pid = %d", s_lock.pid); if (kill(s_lock.pid, 0) == 0) { /* error checking */ if (kill(s_lock.pid, SIGTERM) < 0) { report(s_lock.pid, "kill(SIGTERM) failed"); if (kill(s_lock.pid, SIGKILL) < 0) { report(s_lock.pid, "kill(SIGKILL) failed"); exit(3); } else { report(s_lock.pid, "killed!"); (void) unlink(lock); exit(0); } } else { report(s_lock.pid, "terminated!"); (void) unlink(lock); exit(0); } } else { report(s_lock.pid, "not found"); exit(127); } } debug(s, t) char *s; { (void) fprintf(stderr, s, t); (void) fprintf(stderr, "\n"); } report(pid, msg) int pid; char *msg; { (void) printf("%s: PID %d: %s\n", sysname, pid, msg); } usage(n) int n; { (void) fprintf(stderr, "Usage: %s [-x] -s system\n", myname); exit(n); } ----- 8< here ----- -- Paul Sutcliffe, Jr. +----------------------+ | THINK ... | UUCP (smart): paul@devon.UUCP | or THWIM | UUCP (dumb): ...rutgers!bpa!vu-vlsi!devon!paul +----------------------+