sem_open.3 (fccedf067d9e77523b684f179b4aed07995f7b05) sem_open.3 (26b6c45a92c8eae91cad4a7ce8935e08d2e5d368)
1.\" Copyright (C) 2000 Jason Evans <jasone@FreeBSD.org>.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice(s), this list of conditions and the following disclaimer as

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

21.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27.\"
28.\" $FreeBSD$
1.\" Copyright (C) 2000 Jason Evans <jasone@FreeBSD.org>.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice(s), this list of conditions and the following disclaimer as

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

21.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27.\"
28.\" $FreeBSD$
29.\"
29.Dd January 15, 2003
30.Dt SEM_OPEN 3
31.Os
32.Sh NAME
33.Nm sem_open ,
34.Nm sem_close ,
35.Nm sem_unlink
36.Nd named semaphore operations
37.Sh LIBRARY
38.Lb libc
39.Sh SYNOPSIS
40.In semaphore.h
30.Dd January 15, 2003
31.Dt SEM_OPEN 3
32.Os
33.Sh NAME
34.Nm sem_open ,
35.Nm sem_close ,
36.Nm sem_unlink
37.Nd named semaphore operations
38.Sh LIBRARY
39.Lb libc
40.Sh SYNOPSIS
41.In semaphore.h
41.Ft sem_t *
42.Fn sem_open "const char *name" "int oflag" "..."
42.Ft "sem_t *"
43.Fn sem_open "const char *name" "int oflag" ...
43.Ft int
44.Fn sem_close "sem_t *sem"
45.Ft int
46.Fn sem_unlink "const char *name"
47.Sh DESCRIPTION
48The
49.Fn sem_open
50function creates or opens the named semaphore specified by
51.Fa name .
52The returned semaphore may be used in subsequent calls to
44.Ft int
45.Fn sem_close "sem_t *sem"
46.Ft int
47.Fn sem_unlink "const char *name"
48.Sh DESCRIPTION
49The
50.Fn sem_open
51function creates or opens the named semaphore specified by
52.Fa name .
53The returned semaphore may be used in subsequent calls to
53.Fn sem_getvalue ,
54.Fn sem_wait ,
55.Fn sem_trywait ,
56.Fn sem_post
54.Xr sem_getvalue 3 ,
55.Xr sem_wait 3 ,
56.Xr sem_trywait 3 ,
57.Xr sem_post 3 ,
57and
58.Fn sem_close .
59.Pp
60The following bits may be set in the
61.Fa oflag
62argument:
63.Bl -tag -width ".Dv O_CREAT"
64.It Dv O_CREAT
65Create the semaphore if it does not already exist.
66.Pp
67The third argument to the call to
68.Fn sem_open
69must be of type
70.Vt mode_t
71and specifies the mode for the semaphore.
72Only the
58and
59.Fn sem_close .
60.Pp
61The following bits may be set in the
62.Fa oflag
63argument:
64.Bl -tag -width ".Dv O_CREAT"
65.It Dv O_CREAT
66Create the semaphore if it does not already exist.
67.Pp
68The third argument to the call to
69.Fn sem_open
70must be of type
71.Vt mode_t
72and specifies the mode for the semaphore.
73Only the
73.Dv S_IWUSR ,
74.Dv S_IWGRP ,
74.Dv S_IWUSR , S_IWGRP ,
75and
76.Dv S_IWOTH
77bits are examined;
78it is not possible to grant only
79.Dq read
80permission on a semaphore.
81The mode is modified according to the process's file creation
82mask; see

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

132.Sh ERRORS
133The
134.Fn sem_open
135function will fail if:
136.Bl -tag -width Er
137.It Bq Er EACCES
138The semaphore exists and the permissions specified by
139.Fa oflag
75and
76.Dv S_IWOTH
77bits are examined;
78it is not possible to grant only
79.Dq read
80permission on a semaphore.
81The mode is modified according to the process's file creation
82mask; see

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

132.Sh ERRORS
133The
134.Fn sem_open
135function will fail if:
136.Bl -tag -width Er
137.It Bq Er EACCES
138The semaphore exists and the permissions specified by
139.Fa oflag
140at the time it was created deny access to the this process.
140at the time it was created deny access to this process.
141.It Bq Er EACCES
142The semaphore does not exist, but permission to create it is denied.
143.It Bq Er EEXIST
144.Dv O_CREAT
145and
146.Dv O_EXCL
147are set but the semaphore already exists.
148.It Bq Er EINTR

--- 79 unchanged lines hidden ---
141.It Bq Er EACCES
142The semaphore does not exist, but permission to create it is denied.
143.It Bq Er EEXIST
144.Dv O_CREAT
145and
146.Dv O_EXCL
147are set but the semaphore already exists.
148.It Bq Er EINTR

--- 79 unchanged lines hidden ---