Deleted Added
full compact
uucplock.c (36833) uucplock.c (44652)
1/*
2 * Copyright (c) 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 16 unchanged lines hidden (view full) ---

25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
1/*
2 * Copyright (c) 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 16 unchanged lines hidden (view full) ---

25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * $Id: uucplock.c,v 1.9 1998/05/28 23:17:09 brian Exp $
33 * $Id: uucplock.c,v 1.10 1998/06/10 00:16:28 brian Exp $
34 *
35 */
36
37#ifndef lint
38static const char sccsid[] = "@(#)uucplock.c 8.1 (Berkeley) 6/6/93";
39#endif /* not lint */
40
41#include <sys/types.h>

--- 23 unchanged lines hidden (view full) ---

65/*
66 * uucp style locking routines
67 */
68
69int
70uu_lock(const char *ttyname)
71{
72 int fd, tmpfd, i;
34 *
35 */
36
37#ifndef lint
38static const char sccsid[] = "@(#)uucplock.c 8.1 (Berkeley) 6/6/93";
39#endif /* not lint */
40
41#include <sys/types.h>

--- 23 unchanged lines hidden (view full) ---

65/*
66 * uucp style locking routines
67 */
68
69int
70uu_lock(const char *ttyname)
71{
72 int fd, tmpfd, i;
73 pid_t pid;
73 pid_t pid, pid_old;
74 char lckname[sizeof(_PATH_UUCPLOCK) + MAXNAMLEN],
75 lcktmpname[sizeof(_PATH_UUCPLOCK) + MAXNAMLEN];
76 int err, uuerr;
77
78 pid = getpid();
79 (void)snprintf(lcktmpname, sizeof(lcktmpname), _PATH_UUCPLOCK LOCKTMP,
80 pid);
81 (void)snprintf(lckname, sizeof(lckname), _PATH_UUCPLOCK LOCKFMT,

--- 8 unchanged lines hidden (view full) ---

90 /*
91 * file is already locked
92 * check to see if the process holding the lock
93 * still exists
94 */
95 if ((fd = open(lckname, O_RDONLY)) < 0)
96 GORET(1, UU_LOCK_OPEN_ERR);
97
74 char lckname[sizeof(_PATH_UUCPLOCK) + MAXNAMLEN],
75 lcktmpname[sizeof(_PATH_UUCPLOCK) + MAXNAMLEN];
76 int err, uuerr;
77
78 pid = getpid();
79 (void)snprintf(lcktmpname, sizeof(lcktmpname), _PATH_UUCPLOCK LOCKTMP,
80 pid);
81 (void)snprintf(lckname, sizeof(lckname), _PATH_UUCPLOCK LOCKFMT,

--- 8 unchanged lines hidden (view full) ---

90 /*
91 * file is already locked
92 * check to see if the process holding the lock
93 * still exists
94 */
95 if ((fd = open(lckname, O_RDONLY)) < 0)
96 GORET(1, UU_LOCK_OPEN_ERR);
97
98 if ((pid = get_pid (fd, &err)) == -1)
98 if ((pid_old = get_pid (fd, &err)) == -1)
99 GORET(2, UU_LOCK_READ_ERR);
100
101 close(fd);
102
99 GORET(2, UU_LOCK_READ_ERR);
100
101 close(fd);
102
103 if (kill(pid, 0) == 0 || errno != ESRCH)
103 if (kill(pid_old, 0) == 0 || errno != ESRCH)
104 GORET(1, UU_LOCK_INUSE);
105 /*
106 * The process that locked the file isn't running, so
107 * we'll lock it ourselves
108 */
109 (void)unlink(lckname);
110 } else {
111 if (!put_pid (tmpfd, pid))

--- 118 unchanged lines hidden ---
104 GORET(1, UU_LOCK_INUSE);
105 /*
106 * The process that locked the file isn't running, so
107 * we'll lock it ourselves
108 */
109 (void)unlink(lckname);
110 } else {
111 if (!put_pid (tmpfd, pid))

--- 118 unchanged lines hidden ---