From c08bf286dfc6c2331bce50fadac86457a6a86e4d Mon Sep 17 00:00:00 2001 From: "Andrey A. Chernov" Date: Sat, 4 Mar 1995 00:05:30 +0000 Subject: [PATCH] Use ASCII lock, like everything else does Submitted by: John Capo --- usr.sbin/ppp/uucplock.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/usr.sbin/ppp/uucplock.c b/usr.sbin/ppp/uucplock.c index d9343c6f29fa..c066ca72f4fa 100644 --- a/usr.sbin/ppp/uucplock.c +++ b/usr.sbin/ppp/uucplock.c @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id:$ + * $Id: uucplock.c,v 1.2 1995/02/26 12:18:04 amurai Exp $ * */ @@ -56,6 +56,7 @@ uu_lock(ttyname) 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,12 +71,14 @@ uu_lock(ttyname) perror("lock open"); return(-1); } - if (read(fd, &pid, sizeof(pid)) != sizeof(pid)) { + 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,7 +95,8 @@ uu_lock(ttyname) /* fall out and finish the locking process */ } pid = getpid(); - if (write(fd, (char *)&pid, sizeof(pid)) != sizeof(pid)) { + 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");