From owner-freebsd-bugs Fri Mar 3 10:29:40 1995 Return-Path: bugs-owner Received: (from majordom@localhost) by freefall.cdrom.com (8.6.9/8.6.6) id KAA25650 for bugs-outgoing; Fri, 3 Mar 1995 10:29:40 -0800 Received: from irbs.com ([199.182.75.129]) by freefall.cdrom.com (8.6.9/8.6.6) with ESMTP id KAA25644 for ; Fri, 3 Mar 1995 10:29:37 -0800 Received: (from jc@localhost) by irbs.com (8.6.10/8.6.6) id NAA14005 for freebsd-bugs@freebsd.org; Fri, 3 Mar 1995 13:29:29 -0500 From: John Capo Message-Id: <199503031829.NAA14005@irbs.com> Subject: Patch to make ppp use ascii lock files To: freebsd-bugs@FreeBSD.org Date: Fri, 3 Mar 1995 13:29:26 -0500 (EST) X-Mailer: ELM [version 2.4 PL24] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Length: 1593 Sender: bugs-owner@FreeBSD.org Precedence: bulk While fooling around with uucp and ppp sharing a modem, I discovered that ppp is using binary lock files. John Capo *** uucplock.c.orig Fri Mar 3 13:24:04 1995 --- uucplock.c Fri Mar 3 12:37:02 1995 *************** *** 56,61 **** --- 56,62 ---- extern int errno; int fd, pid; char tbuf[sizeof(_PATH_LOCKDIRNAME) + MAXNAMLEN]; + char pid_buf[64]; off_t lseek(); (void)sprintf(tbuf, _PATH_LOCKDIRNAME, ttyname); *************** *** 70,81 **** perror("lock open"); return(-1); } ! if (read(fd, &pid, sizeof(pid)) != sizeof(pid)) { (void)close(fd); perror("lock read"); return(-1); } if (kill(pid, 0) == 0 || errno != ESRCH) { (void)close(fd); /* process is still running */ return(-1); --- 71,84 ---- perror("lock open"); return(-1); } ! if (read(fd, pid_buf, sizeof(pid_buf)) <= 0) { (void)close(fd); perror("lock read"); return(-1); } + pid = atoi(pid_buf); + if (kill(pid, 0) == 0 || errno != ESRCH) { (void)close(fd); /* process is still running */ return(-1); *************** *** 92,98 **** /* fall out and finish the locking process */ } pid = getpid(); ! if (write(fd, (char *)&pid, sizeof(pid)) != sizeof(pid)) { (void)close(fd); (void)unlink(tbuf); perror("lock write"); --- 95,102 ---- /* fall out and finish the locking process */ } pid = getpid(); ! sprintf(pid_buf, "%10u\n", pid); ! if (write(fd, pid_buf, strlen(pid_buf)) != strlen(pid_buf)) { (void)close(fd); (void)unlink(tbuf); perror("lock write");