diff options
author | ache <ache@FreeBSD.org> | 1995-03-04 00:05:30 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1995-03-04 00:05:30 +0000 |
commit | 80b136e25d2c2f2f5f9ab2c67ab786e841a23aa9 (patch) | |
tree | fa52cf46d86c67aaf33e2eaeff9fbecb76711e32 /usr.sbin/ppp | |
parent | 26dd2c988853b695a6537bb9a356407f2ba9d23e (diff) | |
download | FreeBSD-src-80b136e25d2c2f2f5f9ab2c67ab786e841a23aa9.zip FreeBSD-src-80b136e25d2c2f2f5f9ab2c67ab786e841a23aa9.tar.gz |
Use ASCII lock, like everything else does
Submitted by: John Capo <jc@irbs.com>
Diffstat (limited to 'usr.sbin/ppp')
-rw-r--r-- | usr.sbin/ppp/uucplock.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.sbin/ppp/uucplock.c b/usr.sbin/ppp/uucplock.c index d9343c6..c066ca72 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"); |