Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 3 Mar 1995 13:29:26 -0500 (EST)
From:      John Capo <jc@irbs.com>
To:        freebsd-bugs@FreeBSD.org
Subject:   Patch to make ppp use ascii lock files
Message-ID:  <199503031829.NAA14005@irbs.com>

index | next in thread | raw e-mail

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");



home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199503031829.NAA14005>