diff options
author | Andrey A. Chernov <ache@FreeBSD.org> | 1995-03-04 00:05:30 +0000 |
---|---|---|
committer | Andrey A. Chernov <ache@FreeBSD.org> | 1995-03-04 00:05:30 +0000 |
commit | c08bf286dfc6c2331bce50fadac86457a6a86e4d (patch) | |
tree | fa52cf46d86c67aaf33e2eaeff9fbecb76711e32 /usr.sbin/ppp | |
parent | 3c4d31f1c8199a96ed8ced89ad4d8e48be31b09b (diff) | |
download | src-c08bf286dfc6c2331bce50fadac86457a6a86e4d.tar.gz src-c08bf286dfc6c2331bce50fadac86457a6a86e4d.zip |
Use ASCII lock, like everything else does
Submitted by: John Capo <jc@irbs.com>
Notes
Notes:
svn path=/head/; revision=6873
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 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"); |