From d734c01949a1b0bb3096fc71a4923ad59c58a86e Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Fri, 16 Apr 1999 11:34:27 +0000 Subject: [PATCH] try to cope gracefully with the situation where someone else has locked the serial line for us. --- pppd/utils.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pppd/utils.c b/pppd/utils.c index bec5f89..7c42ce6 100644 --- a/pppd/utils.c +++ b/pppd/utils.c @@ -17,7 +17,7 @@ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint -static char rcsid[] = "$Id: utils.c,v 1.1 1999/04/12 06:24:53 paulus Exp $"; +static char rcsid[] = "$Id: utils.c,v 1.2 1999/04/16 11:34:27 paulus Exp $"; #endif #include @@ -773,7 +773,9 @@ lock(char *dev) lock_buffer[n] = 0; pid = atoi(lock_buffer); #endif /* LOCK_BINARY */ - if (pid == 0 || pid == getpid() + if (pid == getpid()) + return 1; /* somebody else locked it for us */ + if (pid == 0 || (kill(pid, 0) == -1 && errno == ESRCH)) { if (unlink (lock_file) == 0) { notice("Removed stale lock on %s (pid %d)", dev, pid); -- 2.39.2