uucplock.3 (cfeb4fd2736b956f237881cb495918c8f40282af) uucplock.3 (46cf264a2645fc71e5511ba795d85d87ce47dc23)
1.\"
2.\" Copyright (c) 1996 Brian Somers <brian@awfulhak.demon.co.uk>
3.\"
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:

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

18.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
19.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25.\"
1.\"
2.\" Copyright (c) 1996 Brian Somers <brian@awfulhak.demon.co.uk>
3.\"
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:

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

18.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
19.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25.\"
26.\" $Id: uucplock.3,v 1.9 1997/09/29 19:11:25 wosch Exp $
26.\" $Id: uucplock.3,v 1.10 1997/10/07 07:24:50 joerg Exp $
27.\" "
28.Dd March 30, 1997
29.Os
30.Dt uucplock 3
31.Sh NAME
32.Nm uu_lock ,
33.Nm uu_unlock ,
34.Nm uu_lockerr
35.Nd acquire and release control of a serial device
36.Sh SYNOPSIS
37.Fd #include <sys/types.h>
38.Fd #include <libutil.h>
39.Ft int
40.Fn uu_lock "const char *ttyname"
41.Ft int
27.\" "
28.Dd March 30, 1997
29.Os
30.Dt uucplock 3
31.Sh NAME
32.Nm uu_lock ,
33.Nm uu_unlock ,
34.Nm uu_lockerr
35.Nd acquire and release control of a serial device
36.Sh SYNOPSIS
37.Fd #include <sys/types.h>
38.Fd #include <libutil.h>
39.Ft int
40.Fn uu_lock "const char *ttyname"
41.Ft int
42.Fn uu_lock_txfr "const char *ttyname" "pid_t pid"
43.Ft int
42.Fn uu_unlock "const char *ttyname"
43.Ft const char *
44.Fn uu_lockerr "int uu_lockresult"
45.Pp
46Link with
47.Va -lutil
48on the
49.Xr cc 1

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

58If the file already exists, it is expected to contain the process
59id of the locking program.
60.Pp
61If the file does not already exist, or the owning process given by
62the process id found in the lock file is no longer running,
63.Fn uu_lock
64will write its own process id into the file and return success.
65.Pp
44.Fn uu_unlock "const char *ttyname"
45.Ft const char *
46.Fn uu_lockerr "int uu_lockresult"
47.Pp
48Link with
49.Va -lutil
50on the
51.Xr cc 1

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

60If the file already exists, it is expected to contain the process
61id of the locking program.
62.Pp
63If the file does not already exist, or the owning process given by
64the process id found in the lock file is no longer running,
65.Fn uu_lock
66will write its own process id into the file and return success.
67.Pp
68.Fn uu_lock_txfr
69transfers lock ownership to another process.
70.Fn uu_lock
71must have previously been successful.
72.Pp
66.Fn uu_unlock
67removes the lockfile created by
68.Fn uu_lock
69for the given
70.Fa ttyname .
71Care should be taken that
72.Fn uu_lock
73was successful before calling

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

125uses the current value of
126.Va errno
127to determine the exact error. Care should be made not to allow
128.Va errno
129to be changed between calls to
130.Fn uu_lock
131and
132.Fn uu_lockerr .
73.Fn uu_unlock
74removes the lockfile created by
75.Fn uu_lock
76for the given
77.Fa ttyname .
78Care should be taken that
79.Fn uu_lock
80was successful before calling

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

132uses the current value of
133.Va errno
134to determine the exact error. Care should be made not to allow
135.Va errno
136to be changed between calls to
137.Fn uu_lock
138and
139.Fn uu_lockerr .
140.Pp
141.Fn uu_lock_txfr
142may return any of the following values:
143.Pp
144.Dv UU_LOCK_OK:
145The transfer was successful. The specified process now holds the device
146lock.
147.Pp
148.Dv UU_LOCK_OWNER_ERR:
149The current process does not already own a lock on the specified device.
150.Pp
151.Dv UU_LOCK_WRITE_ERR:
152The new process id could not be written to the lock file via a call to
153.Xr write 2 .
133.Sh ERRORS
134If
135.Fn uu_lock
154.Sh ERRORS
155If
156.Fn uu_lock
136returns one of the four error values above, the global value
157returns one of the error values above, the global value
137.Va errno
138can be used to determine the cause. Refer to the respective manual pages
139for further details.
140.Pp
141.Fn uu_unlock
142will set the global variable
143.Va errno
144to reflect the reason that the lock file could not be removed.

--- 18 unchanged lines hidden ---
158.Va errno
159can be used to determine the cause. Refer to the respective manual pages
160for further details.
161.Pp
162.Fn uu_unlock
163will set the global variable
164.Va errno
165to reflect the reason that the lock file could not be removed.

--- 18 unchanged lines hidden ---