Date: Sat, 23 Mar 1996 14:56:48 -0900 (AKST) From: loodvrij@gridpoint.com (Bruce J. Keeler) To: current@freebsd.org Subject: Patch to talkd Message-ID: <m0u0dAu-0006etC@cyb>
next in thread | raw e-mail | index | archive | help
I've a tendancy to leave myself logged in a time or two on the console, then go and do real work on an Xterm somewhere else. The problem with this is that incoming talk requests go to the first matching utmp entry, usually the console vtys, and I usually miss them. Here is a patch to talkd which makes it send the request to the tty with the lowest idle time. -- Bruce J. Keeler Internet: loodvrij@gridpoint.com -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- "The thing with beating your head against a wall is that it feels so *good* when you stop." *** process.c.old Sat Oct 22 09:37:06 1994 --- process.c Sat Mar 23 14:46:39 1996 *************** *** 190,195 **** --- 190,196 ---- int status; FILE *fd; struct stat statb; + time_t best = 0; char line[sizeof(ubuf.ut_line) + 1]; char ftty[sizeof(_PATH_DEV) - 1 + sizeof(line)]; *************** *** 204,220 **** if (SCMPN(ubuf.ut_name, name) == 0) { strncpy(line, ubuf.ut_line, sizeof(ubuf.ut_line)); line[sizeof(ubuf.ut_line)] = '\0'; ! if (*tty == '\0') { ! status = PERMISSION_DENIED; /* no particular tty was requested */ (void) strcpy(ftty + sizeof(_PATH_DEV) - 1, line); if (stat(ftty, &statb) == 0) { if (!(statb.st_mode & 020)) continue; ! (void) strcpy(tty, line); ! status = SUCCESS; ! break; } } if (strcmp(line, tty) == 0) { --- 205,225 ---- if (SCMPN(ubuf.ut_name, name) == 0) { strncpy(line, ubuf.ut_line, sizeof(ubuf.ut_line)); line[sizeof(ubuf.ut_line)] = '\0'; ! if (*tty == '\0' || best != 0) { ! if (best == 0) ! status = PERMISSION_DENIED; /* no particular tty was requested */ (void) strcpy(ftty + sizeof(_PATH_DEV) - 1, line); if (stat(ftty, &statb) == 0) { if (!(statb.st_mode & 020)) continue; ! if (statb.st_atime > best) { ! best = statb.st_atime; ! (void) strcpy(tty, line); ! status = SUCCESS; ! continue; ! } } } if (strcmp(line, tty) == 0) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?m0u0dAu-0006etC>