version 1.7, 2002/05/07 06:56:50 |
version 1.8, 2002/05/29 09:23:25 |
|
|
uu_lock(ttyname) |
uu_lock(ttyname) |
char *ttyname; |
char *ttyname; |
{ |
{ |
int fd, pid; |
int fd, len; |
char tbuf[sizeof(_PATH_LOCKDIRNAME) + MAXNAMLEN]; |
char tbuf[sizeof(_PATH_LOCKDIRNAME) + MAXNAMLEN]; |
char text_pid[81]; |
char text_pid[81]; |
int len; |
pid_t pid; |
|
|
(void)snprintf(tbuf, sizeof tbuf, _PATH_LOCKDIRNAME, ttyname); |
(void)snprintf(tbuf, sizeof tbuf, _PATH_LOCKDIRNAME, ttyname); |
fd = open(tbuf, O_RDWR|O_CREAT|O_EXCL, 0660); |
fd = open(tbuf, O_RDWR|O_CREAT|O_EXCL, 0660); |
|
|
/* fall out and finish the locking process */ |
/* fall out and finish the locking process */ |
} |
} |
pid = getpid(); |
pid = getpid(); |
(void)sprintf(text_pid, "%10d\n", pid); |
(void)snprintf(text_pid, sizeof text_pid, "%10ld\n", (long)pid); |
len = strlen(text_pid); |
len = strlen(text_pid); |
if (write(fd, text_pid, len) != len) { |
if (write(fd, text_pid, len) != len) { |
(void)close(fd); |
(void)close(fd); |