From owner-freebsd-current Sat Mar 23 16:00:24 1996 Return-Path: owner-current Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id QAA20463 for current-outgoing; Sat, 23 Mar 1996 16:00:24 -0800 (PST) Received: from cyb (cyb.alaska.net [204.17.139.166]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id QAA20457 for ; Sat, 23 Mar 1996 16:00:17 -0800 (PST) Received: by cyb (Smail3.1.29.1 #9) id m0u0dAu-0006etC; Sat, 23 Mar 96 14:56 AKST Message-Id: From: loodvrij@gridpoint.com (Bruce J. Keeler) Subject: Patch to talkd To: current@freebsd.org Date: Sat, 23 Mar 1996 14:56:48 -0900 (AKST) X-Mailer: ELM [version 2.4 PL24] Content-Type: text Sender: owner-current@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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) {