# SOME DESCRIPTIVE TITLE
# Copyright (C) YEAR Free Software Foundation, Inc.
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2012-05-01 04:39+0900\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

#. type: TH
#: build/C/man3/sem_close.3:26
#, no-wrap
msgid "SEM_CLOSE"
msgstr ""

#. type: TH
#: build/C/man3/sem_close.3:26 build/C/man3/sem_destroy.3:26 build/C/man3/sem_getvalue.3:26 build/C/man3/sem_unlink.3:26
#, no-wrap
msgid "2006-03-25"
msgstr ""

#. type: TH
#: build/C/man3/sem_close.3:26 build/C/man3/sem_destroy.3:26 build/C/man3/sem_getvalue.3:26 build/C/man3/sem_init.3:26 build/C/man3/sem_open.3:26 build/C/man7/sem_overview.7:26 build/C/man3/sem_post.3:26 build/C/man3/sem_unlink.3:26 build/C/man3/sem_wait.3:26 build/C/man2/semctl.2:39 build/C/man2/semget.2:34 build/C/man2/semop.2:33
#, no-wrap
msgid "Linux"
msgstr ""

#. type: TH
#: build/C/man3/sem_close.3:26 build/C/man3/sem_destroy.3:26 build/C/man3/sem_getvalue.3:26 build/C/man3/sem_init.3:26 build/C/man3/sem_open.3:26 build/C/man7/sem_overview.7:26 build/C/man3/sem_post.3:26 build/C/man3/sem_unlink.3:26 build/C/man3/sem_wait.3:26 build/C/man2/semctl.2:39 build/C/man2/semget.2:34 build/C/man2/semop.2:33
#, no-wrap
msgid "Linux Programmer's Manual"
msgstr ""

#. type: SH
#: build/C/man3/sem_close.3:27 build/C/man3/sem_destroy.3:27 build/C/man3/sem_getvalue.3:27 build/C/man3/sem_init.3:27 build/C/man3/sem_open.3:27 build/C/man7/sem_overview.7:27 build/C/man3/sem_post.3:27 build/C/man3/sem_unlink.3:27 build/C/man3/sem_wait.3:27 build/C/man2/semctl.2:40 build/C/man2/semget.2:35 build/C/man2/semop.2:34
#, no-wrap
msgid "NAME"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_close.3:29
msgid "sem_close - close a named semaphore"
msgstr ""

#. type: SH
#: build/C/man3/sem_close.3:29 build/C/man3/sem_destroy.3:29 build/C/man3/sem_getvalue.3:29 build/C/man3/sem_init.3:29 build/C/man3/sem_open.3:29 build/C/man3/sem_post.3:29 build/C/man3/sem_unlink.3:29 build/C/man3/sem_wait.3:29 build/C/man2/semctl.2:42 build/C/man2/semget.2:37 build/C/man2/semop.2:36
#, no-wrap
msgid "SYNOPSIS"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_close.3:32 build/C/man3/sem_destroy.3:32 build/C/man3/sem_getvalue.3:32 build/C/man3/sem_init.3:32 build/C/man3/sem_post.3:32 build/C/man3/sem_unlink.3:32 build/C/man3/sem_wait.3:32
#, no-wrap
msgid "B<#include E<lt>semaphore.hE<gt>>\n"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_close.3:34
#, no-wrap
msgid "B<int sem_close(sem_t *>I<sem>B<);>\n"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_close.3:37 build/C/man3/sem_destroy.3:37 build/C/man3/sem_getvalue.3:37 build/C/man3/sem_init.3:37 build/C/man3/sem_open.3:41 build/C/man3/sem_post.3:37 build/C/man3/sem_unlink.3:37 build/C/man3/sem_wait.3:41
msgid "Link with I<-lrt> or I<-pthread>."
msgstr ""

#. type: SH
#: build/C/man3/sem_close.3:37 build/C/man3/sem_destroy.3:37 build/C/man3/sem_getvalue.3:37 build/C/man3/sem_init.3:37 build/C/man3/sem_open.3:41 build/C/man7/sem_overview.7:29 build/C/man3/sem_post.3:37 build/C/man3/sem_unlink.3:37 build/C/man3/sem_wait.3:49 build/C/man2/semctl.2:50 build/C/man2/semget.2:47 build/C/man2/semop.2:55
#, no-wrap
msgid "DESCRIPTION"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_close.3:43
msgid ""
"B<sem_close>()  closes the named semaphore referred to by I<sem>, allowing "
"any resources that the system has allocated to the calling process for this "
"semaphore to be freed."
msgstr ""

#. type: SH
#: build/C/man3/sem_close.3:43 build/C/man3/sem_destroy.3:55 build/C/man3/sem_getvalue.3:54 build/C/man3/sem_init.3:77 build/C/man3/sem_open.3:104 build/C/man3/sem_post.3:45 build/C/man3/sem_unlink.3:44 build/C/man3/sem_wait.3:108 build/C/man2/semctl.2:338 build/C/man2/semget.2:155 build/C/man2/semop.2:309
#, no-wrap
msgid "RETURN VALUE"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_close.3:49
msgid ""
"On success B<sem_close>()  returns 0; on error, -1 is returned, with "
"I<errno> set to indicate the error."
msgstr ""

#. type: SH
#: build/C/man3/sem_close.3:49 build/C/man3/sem_destroy.3:61 build/C/man3/sem_getvalue.3:60 build/C/man3/sem_init.3:83 build/C/man3/sem_open.3:116 build/C/man3/sem_post.3:52 build/C/man3/sem_unlink.3:50 build/C/man3/sem_wait.3:114 build/C/man2/semctl.2:385 build/C/man2/semget.2:161 build/C/man2/semop.2:319
#, no-wrap
msgid "ERRORS"
msgstr ""

#. type: TP
#: build/C/man3/sem_close.3:50 build/C/man3/sem_destroy.3:62 build/C/man3/sem_getvalue.3:61 build/C/man3/sem_init.3:84 build/C/man3/sem_open.3:132 build/C/man3/sem_open.3:137 build/C/man3/sem_post.3:53 build/C/man3/sem_wait.3:119 build/C/man3/sem_wait.3:133 build/C/man2/semctl.2:418 build/C/man2/semget.2:186 build/C/man2/semop.2:367
#, no-wrap
msgid "B<EINVAL>"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_close.3:54 build/C/man3/sem_destroy.3:66 build/C/man3/sem_getvalue.3:65 build/C/man3/sem_post.3:57 build/C/man3/sem_wait.3:123
msgid "I<sem> is not a valid semaphore."
msgstr ""

#. type: SH
#: build/C/man3/sem_close.3:54 build/C/man3/sem_destroy.3:66 build/C/man3/sem_getvalue.3:65 build/C/man3/sem_init.3:95 build/C/man3/sem_open.3:170 build/C/man7/sem_overview.7:138 build/C/man3/sem_post.3:61 build/C/man3/sem_unlink.3:62 build/C/man3/sem_wait.3:143 build/C/man2/semctl.2:460 build/C/man2/semget.2:217 build/C/man2/semop.2:397
#, no-wrap
msgid "CONFORMING TO"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_close.3:56 build/C/man3/sem_destroy.3:68 build/C/man3/sem_getvalue.3:67 build/C/man3/sem_init.3:97 build/C/man3/sem_open.3:172 build/C/man7/sem_overview.7:140 build/C/man3/sem_post.3:63 build/C/man3/sem_unlink.3:64 build/C/man3/sem_wait.3:145
msgid "POSIX.1-2001."
msgstr ""

#. type: SH
#: build/C/man3/sem_close.3:56 build/C/man3/sem_destroy.3:68 build/C/man3/sem_getvalue.3:67 build/C/man3/sem_init.3:97 build/C/man7/sem_overview.7:140 build/C/man3/sem_post.3:63 build/C/man3/sem_wait.3:145 build/C/man2/semctl.2:463 build/C/man2/semget.2:221 build/C/man2/semop.2:400
#, no-wrap
msgid "NOTES"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_close.3:60
msgid ""
"All open named semaphores are automatically closed on process termination, "
"or upon B<execve>(2)."
msgstr ""

#. type: SH
#: build/C/man3/sem_close.3:60 build/C/man3/sem_destroy.3:74 build/C/man3/sem_getvalue.3:71 build/C/man3/sem_init.3:102 build/C/man3/sem_open.3:172 build/C/man7/sem_overview.7:152 build/C/man3/sem_post.3:70 build/C/man3/sem_unlink.3:64 build/C/man3/sem_wait.3:262 build/C/man2/semctl.2:509 build/C/man2/semget.2:279 build/C/man2/semop.2:513
#, no-wrap
msgid "SEE ALSO"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_close.3:67
msgid ""
"B<sem_getvalue>(3), B<sem_open>(3), B<sem_post>(3), B<sem_unlink>(3), "
"B<sem_wait>(3), B<sem_overview>(7)"
msgstr ""

#. type: SH
#: build/C/man3/sem_close.3:67 build/C/man3/sem_destroy.3:79 build/C/man3/sem_getvalue.3:75 build/C/man3/sem_init.3:107 build/C/man3/sem_open.3:179 build/C/man7/sem_overview.7:162 build/C/man3/sem_post.3:74 build/C/man3/sem_unlink.3:70 build/C/man3/sem_wait.3:268 build/C/man2/semctl.2:516 build/C/man2/semget.2:286 build/C/man2/semop.2:521
#, no-wrap
msgid "COLOPHON"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_close.3:74 build/C/man3/sem_destroy.3:86 build/C/man3/sem_getvalue.3:82 build/C/man3/sem_init.3:114 build/C/man3/sem_open.3:186 build/C/man7/sem_overview.7:169 build/C/man3/sem_post.3:81 build/C/man3/sem_unlink.3:77 build/C/man3/sem_wait.3:275 build/C/man2/semctl.2:523 build/C/man2/semget.2:293 build/C/man2/semop.2:528
msgid ""
"This page is part of release 3.40 of the Linux I<man-pages> project.  A "
"description of the project, and information about reporting bugs, can be "
"found at http://www.kernel.org/doc/man-pages/."
msgstr ""

#. type: TH
#: build/C/man3/sem_destroy.3:26
#, no-wrap
msgid "SEM_DESTROY"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_destroy.3:29
msgid "sem_destroy - destroy an unnamed semaphore"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_destroy.3:34
#, no-wrap
msgid "B<int sem_destroy(sem_t *>I<sem>B<);>\n"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_destroy.3:41
msgid ""
"B<sem_destroy>()  destroys the unnamed semaphore at the address pointed to "
"by I<sem>."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_destroy.3:46
msgid ""
"Only a semaphore that has been initialized by B<sem_init>(3)  should be "
"destroyed using B<sem_destroy>()."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_destroy.3:51
msgid ""
"Destroying a semaphore that other processes or threads are currently blocked "
"on (in B<sem_wait>(3))  produces undefined behavior."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_destroy.3:55
msgid ""
"Using a semaphore that has been destroyed produces undefined results, until "
"the semaphore has been reinitialized using B<sem_init>(3)."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_destroy.3:61
msgid ""
"B<sem_destroy>()  returns 0 on success; on error, -1 is returned, and "
"I<errno> is set to indicate the error."
msgstr ""

#.  But not on NPTL, where sem_destroy () is a no-op..
#. type: Plain text
#: build/C/man3/sem_destroy.3:74
msgid ""
"An unnamed semaphore should be destroyed with B<sem_destroy>()  before the "
"memory in which it is located is deallocated.  Failure to do this can result "
"in resource leaks on some implementations."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_destroy.3:79
msgid "B<sem_init>(3), B<sem_post>(3), B<sem_wait>(3), B<sem_overview>(7)"
msgstr ""

#. type: TH
#: build/C/man3/sem_getvalue.3:26
#, no-wrap
msgid "SEM_GETVALUE"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_getvalue.3:29
msgid "sem_getvalue - get the value of a semaphore"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_getvalue.3:34
#, no-wrap
msgid "B<int sem_getvalue(sem_t *>I<sem>B<, int *>I<sval>B<);>\n"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_getvalue.3:43
msgid ""
"B<sem_getvalue>()  places the current value of the semaphore pointed to "
"I<sem> into the integer pointed to by I<sval>."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_getvalue.3:54
msgid ""
"If one or more processes or threads are blocked waiting to lock the "
"semaphore with B<sem_wait>(3), POSIX.1-2001 permits two possibilities for "
"the value returned in I<sval>: either 0 is returned; or a negative number "
"whose absolute value is the count of the number of processes and threads "
"currently blocked in B<sem_wait>(3).  Linux adopts the former behavior."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_getvalue.3:60
msgid ""
"B<sem_getvalue>()  returns 0 on success; on error, -1 is returned and "
"I<errno> is set to indicate the error."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_getvalue.3:71
msgid ""
"The value of the semaphore may already have changed by the time "
"B<sem_getvalue>()  returns."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_getvalue.3:75
msgid "B<sem_post>(3), B<sem_wait>(3), B<sem_overview>(7)"
msgstr ""

#. type: TH
#: build/C/man3/sem_init.3:26
#, no-wrap
msgid "SEM_INIT"
msgstr ""

#. type: TH
#: build/C/man3/sem_init.3:26
#, no-wrap
msgid "2008-07-27"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_init.3:29
msgid "sem_init - initialize an unnamed semaphore"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_init.3:34
#, no-wrap
msgid ""
"B<int sem_init(sem_t *>I<sem>B<, int >I<pshared>B<, unsigned int "
">I<value>B<);>\n"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_init.3:44
msgid ""
"B<sem_init>()  initializes the unnamed semaphore at the address pointed to "
"by I<sem>.  The I<value> argument specifies the initial value for the "
"semaphore."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_init.3:49
msgid ""
"The I<pshared> argument indicates whether this semaphore is to be shared "
"between the threads of a process, or between processes."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_init.3:57
msgid ""
"If I<pshared> has the value 0, then the semaphore is shared between the "
"threads of a process, and should be located at some address that is visible "
"to all threads (e.g., a global variable, or a variable allocated dynamically "
"on the heap)."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_init.3:74
msgid ""
"If I<pshared> is nonzero, then the semaphore is shared between processes, "
"and should be located in a region of shared memory (see B<shm_open>(3), "
"B<mmap>(2), and B<shmget>(2)).  (Since a child created by B<fork>(2)  "
"inherits its parent's memory mappings, it can also access the semaphore.)  "
"Any process that can access the shared memory region can operate on the "
"semaphore using B<sem_post>(3), B<sem_wait>(3), etc."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_init.3:77
msgid ""
"Initializing a semaphore that has already been initialized results in "
"undefined behavior."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_init.3:83
msgid ""
"B<sem_init>()  returns 0 on success; on error, -1 is returned, and I<errno> "
"is set to indicate the error."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_init.3:89
msgid "I<value> exceeds B<SEM_VALUE_MAX>."
msgstr ""

#. type: TP
#: build/C/man3/sem_init.3:89
#, no-wrap
msgid "B<ENOSYS>"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_init.3:95
msgid ""
"I<pshared> is nonzero, but the system does not support process-shared "
"semaphores (see B<sem_overview>(7))."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_init.3:102
msgid ""
"Bizarrely, POSIX.1-2001 does not specify the value that should be returned "
"by a successful call to B<sem_init>().  POSIX.1-2008 rectifies this, "
"specifying the zero return on success."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_init.3:107
msgid "B<sem_destroy>(3), B<sem_post>(3), B<sem_wait>(3), B<sem_overview>(7)"
msgstr ""

#. type: TH
#: build/C/man3/sem_open.3:26
#, no-wrap
msgid "SEM_OPEN"
msgstr ""

#. type: TH
#: build/C/man3/sem_open.3:26
#, no-wrap
msgid "2009-02-20"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_open.3:29
msgid "sem_open - initialize and open a named semaphore"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_open.3:34
#, no-wrap
msgid ""
"B<#include E<lt>fcntl.hE<gt>>           /* For O_* constants */\n"
"B<#include E<lt>sys/stat.hE<gt>>        /* For mode constants */\n"
"B<#include E<lt>semaphore.hE<gt>>\n"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_open.3:38
#, no-wrap
msgid ""
"B<sem_t *sem_open(const char *>I<name>B<, int >I<oflag>B<);>\n"
"B<sem_t *sem_open(const char *>I<name>B<, int >I<oflag>B<, >\n"
"B<                mode_t >I<mode>B<, unsigned int >I<value>B<);>\n"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_open.3:50
msgid ""
"B<sem_open>()  creates a new POSIX semaphore or opens an existing "
"semaphore.  The semaphore is identified by I<name>.  For details of the "
"construction of I<name>, see B<sem_overview>(7)."
msgstr ""

#.  In reality the file system IDs are used on Linux.
#. type: Plain text
#: build/C/man3/sem_open.3:76
msgid ""
"The I<oflag> argument specifies flags that control the operation of the "
"call.  (Definitions of the flags values can be obtained by including "
"I<E<lt>fcntl.hE<gt>>.)  If B<O_CREAT> is specified in I<oflag>, then the "
"semaphore is created if it does not already exist.  The owner (user ID) of "
"the semaphore is set to the effective user ID of the calling process.  The "
"group ownership (group ID) is set to the effective group ID of the calling "
"process.  If both B<O_CREAT> and B<O_EXCL> are specified in I<oflag>, then "
"an error is returned if a semaphore with the given I<name> already exists."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_open.3:104
msgid ""
"If B<O_CREAT> is specified in I<oflag>, then two additional arguments must "
"be supplied.  The I<mode> argument specifies the permissions to be placed on "
"the new semaphore, as for B<open>(2).  (Symbolic definitions for the "
"permissions bits can be obtained by including I<E<lt>sys/stat.hE<gt>>.)  The "
"permissions settings are masked against the process umask.  Both read and "
"write permission should be granted to each class of user that will access "
"the semaphore.  The I<value> argument specifies the initial value for the "
"new semaphore.  If B<O_CREAT> is specified, and a semaphore with the given "
"I<name> already exists, then I<mode> and I<value> are ignored."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_open.3:116
msgid ""
"On success, B<sem_open>()  returns the address of the new semaphore; this "
"address is used when calling other semaphore-related functions.  On error, "
"B<sem_open>()  returns B<SEM_FAILED>, with I<errno> set to indicate the "
"error."
msgstr ""

#. type: TP
#: build/C/man3/sem_open.3:117 build/C/man3/sem_unlink.3:51 build/C/man2/semctl.2:389 build/C/man2/semget.2:165 build/C/man2/semop.2:331
#, no-wrap
msgid "B<EACCES>"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_open.3:121
msgid "The semaphore exists, but the caller does not have permission to open it."
msgstr ""

#. type: TP
#: build/C/man3/sem_open.3:121 build/C/man2/semget.2:173
#, no-wrap
msgid "B<EEXIST>"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_open.3:132
msgid ""
"Both B<O_CREAT> and B<O_EXCL> were specified in I<oflag>, but a semaphore "
"with this I<name> already exists."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_open.3:137
msgid "I<value> was greater than B<SEM_VALUE_MAX>."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_open.3:141
msgid "I<name> consists of just \"/\", followed by no other characters."
msgstr ""

#. type: TP
#: build/C/man3/sem_open.3:141
#, no-wrap
msgid "B<EMFILE>"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_open.3:144
msgid "The process already has the maximum number of files and open."
msgstr ""

#. type: TP
#: build/C/man3/sem_open.3:144 build/C/man3/sem_unlink.3:54
#, no-wrap
msgid "B<ENAMETOOLONG>"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_open.3:148 build/C/man3/sem_unlink.3:58
msgid "I<name> was too long."
msgstr ""

#. type: TP
#: build/C/man3/sem_open.3:148
#, no-wrap
msgid "B<ENFILE>"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_open.3:151
msgid "The system limit on the total number of open files has been reached."
msgstr ""

#. type: TP
#: build/C/man3/sem_open.3:151 build/C/man3/sem_unlink.3:58 build/C/man2/semget.2:197
#, no-wrap
msgid "B<ENOENT>"
msgstr ""

#.  this error can occur if we have a name of the (nonportable) form
#.  /dir/name, and the directory /dev/shm/dir does not exist.
#. type: Plain text
#: build/C/man3/sem_open.3:167
msgid ""
"The B<O_CREAT> flag was not specified in I<oflag> and no semaphore with this "
"I<name> exists; or, B<O_CREAT> was specified, but I<name> wasn't well "
"formed."
msgstr ""

#. type: TP
#: build/C/man3/sem_open.3:167 build/C/man2/semget.2:205 build/C/man2/semop.2:374
#, no-wrap
msgid "B<ENOMEM>"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_open.3:170
msgid "Insufficient memory."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_open.3:179
msgid ""
"B<sem_close>(3), B<sem_getvalue>(3), B<sem_post>(3), B<sem_unlink>(3), "
"B<sem_wait>(3), B<sem_overview>(7)"
msgstr ""

#. type: TH
#: build/C/man7/sem_overview.7:26
#, no-wrap
msgid "SEM_OVERVIEW"
msgstr ""

#. type: TH
#: build/C/man7/sem_overview.7:26
#, no-wrap
msgid "2010-05-22"
msgstr ""

#. type: Plain text
#: build/C/man7/sem_overview.7:29
msgid "sem_overview - Overview of POSIX semaphores"
msgstr ""

#. type: Plain text
#: build/C/man7/sem_overview.7:31
msgid "POSIX semaphores allow processes and threads to synchronize their actions."
msgstr ""

#. type: Plain text
#: build/C/man7/sem_overview.7:41
msgid ""
"A semaphore is an integer whose value is never allowed to fall below zero.  "
"Two operations can be performed on semaphores: increment the semaphore value "
"by one (B<sem_post>(3)); and decrement the semaphore value by one "
"(B<sem_wait>(3)).  If the value of a semaphore is currently zero, then a "
"B<sem_wait>(3)  operation will block until the value becomes greater than "
"zero."
msgstr ""

#. type: Plain text
#: build/C/man7/sem_overview.7:44
msgid "POSIX semaphores come in two forms: named semaphores and unnamed semaphores."
msgstr ""

#. type: TP
#: build/C/man7/sem_overview.7:44
#, no-wrap
msgid "B<Named semaphores>"
msgstr ""

#.  glibc allows the initial slash to be omitted, and makes
#.  multiple initial slashes equivalent to a single slash.
#.  This differs from the implementation of POSIX message queues.
#.  glibc allows subdirectory components in the name, in which
#.  case the subdirectory tree must exist under /dev/shm, and
#.  the fist subdirectory component must exist as the name
#.  sem.name, and all of the subdirectory components must allow the
#.  required permissions if a user wants to create a semaphore
#.  object in a subdirectory.
#. type: Plain text
#: build/C/man7/sem_overview.7:64
msgid ""
"A named semaphore is identified by a name of the form I</somename>; that is, "
"a null-terminated string of up to B<NAME_MAX>I<-4> (i.e., 251) characters "
"consisting of an initial slash, followed by one or more characters, none of "
"which are slashes.  Two processes can operate on the same named semaphore by "
"passing the same name to B<sem_open>(3)."
msgstr ""

#. type: Plain text
#: build/C/man7/sem_overview.7:79
msgid ""
"The B<sem_open>(3)  function creates a new named semaphore or opens an "
"existing named semaphore.  After the semaphore has been opened, it can be "
"operated on using B<sem_post>(3)  and B<sem_wait>(3).  When a process has "
"finished using the semaphore, it can use B<sem_close>(3)  to close the "
"semaphore.  When all processes have finished using the semaphore, it can be "
"removed from the system using B<sem_unlink>(3)."
msgstr ""

#. type: TP
#: build/C/man7/sem_overview.7:79
#, no-wrap
msgid "B<Unnamed semaphores (memory-based semaphores)>"
msgstr ""

#. type: Plain text
#: build/C/man7/sem_overview.7:94
msgid ""
"An unnamed semaphore does not have a name.  Instead the semaphore is placed "
"in a region of memory that is shared between multiple threads (a "
"I<thread-shared semaphore>)  or processes (a I<process-shared semaphore>).  "
"A thread-shared semaphore is placed in an area of memory shared between the "
"threads of a process, for example, a global variable.  A process-shared "
"semaphore must be placed in a shared memory region (e.g., a System V shared "
"memory segment created using B<shmget>(2), or a POSIX shared memory object "
"built created using B<shm_open>(3))."
msgstr ""

#. type: Plain text
#: build/C/man7/sem_overview.7:105
msgid ""
"Before being used, an unnamed semaphore must be initialized using "
"B<sem_init>(3).  It can then be operated on using B<sem_post>(3)  and "
"B<sem_wait>(3).  When the semaphore is no longer required, and before the "
"memory in which it is located is deallocated, the semaphore should be "
"destroyed using B<sem_destroy>(3)."
msgstr ""

#. type: Plain text
#: build/C/man7/sem_overview.7:108
msgid ""
"The remainder of this section describes some specific details of the Linux "
"implementation of POSIX semaphores."
msgstr ""

#. type: SS
#: build/C/man7/sem_overview.7:108
#, no-wrap
msgid "Versions"
msgstr ""

#. type: Plain text
#: build/C/man7/sem_overview.7:114
msgid ""
"Prior to kernel 2.6, Linux only supported unnamed, thread-shared "
"semaphores.  On a system with Linux 2.6 and a glibc that provides the NPTL "
"threading implementation, a complete implementation of POSIX semaphores is "
"provided."
msgstr ""

#. type: SS
#: build/C/man7/sem_overview.7:114
#, no-wrap
msgid "Persistence"
msgstr ""

#. type: Plain text
#: build/C/man7/sem_overview.7:119
msgid ""
"POSIX named semaphores have kernel persistence: if not removed by "
"B<sem_unlink>(3), a semaphore will exist until the system is shut down."
msgstr ""

#. type: SS
#: build/C/man7/sem_overview.7:119
#, no-wrap
msgid "Linking"
msgstr ""

#. type: Plain text
#: build/C/man7/sem_overview.7:124
msgid ""
"Programs using the POSIX semaphores API must be compiled with I<cc -lrt> to "
"link against the real-time library, I<librt>."
msgstr ""

#. type: SS
#: build/C/man7/sem_overview.7:124
#, no-wrap
msgid "Accessing named semaphores via the file system"
msgstr ""

#. type: Plain text
#: build/C/man7/sem_overview.7:135
msgid ""
"On Linux, named semaphores are created in a virtual file system, normally "
"mounted under I</dev/shm>, with names of the form B<sem.>I<somename>.  (This "
"is the reason that semaphore names are limited to B<NAME_MAX>I<-4> rather "
"than B<NAME_MAX> characters.)"
msgstr ""

#. type: Plain text
#: build/C/man7/sem_overview.7:138
msgid ""
"Since Linux 2.6.19, ACLs can be placed on files under this directory, to "
"control object permissions on a per-user and per-group basis."
msgstr ""

#. type: Plain text
#: build/C/man7/sem_overview.7:149
msgid ""
"System V semaphores (B<semget>(2), B<semop>(2), etc.) are an older semaphore "
"API.  POSIX semaphores provide a simpler, and better designed interface than "
"System V semaphores; on the other hand POSIX semaphores are less widely "
"available (especially on older systems) than System V semaphores."
msgstr ""

#. type: SH
#: build/C/man7/sem_overview.7:149 build/C/man3/sem_post.3:67 build/C/man3/sem_wait.3:153 build/C/man2/semop.2:488
#, no-wrap
msgid "EXAMPLE"
msgstr ""

#. type: Plain text
#: build/C/man7/sem_overview.7:152
msgid ""
"An example of the use of various POSIX semaphore functions is shown in "
"B<sem_wait>(3)."
msgstr ""

#. type: Plain text
#: build/C/man7/sem_overview.7:162
msgid ""
"B<sem_close>(3), B<sem_destroy>(3), B<sem_getvalue>(3), B<sem_init>(3), "
"B<sem_open>(3), B<sem_post>(3), B<sem_unlink>(3), B<sem_wait>(3), "
"B<pthreads>(7)"
msgstr ""

#. type: TH
#: build/C/man3/sem_post.3:26
#, no-wrap
msgid "SEM_POST"
msgstr ""

#. type: TH
#: build/C/man3/sem_post.3:26
#, no-wrap
msgid "2009-03-30"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_post.3:29
msgid "sem_post - unlock a semaphore"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_post.3:34
#, no-wrap
msgid "B<int sem_post(sem_t *>I<sem>B<);>\n"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_post.3:45
msgid ""
"B<sem_post>()  increments (unlocks) the semaphore pointed to by I<sem>.  If "
"the semaphore's value consequently becomes greater than zero, then another "
"process or thread blocked in a B<sem_wait>(3)  call will be woken up and "
"proceed to lock the semaphore."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_post.3:52
msgid ""
"B<sem_post>()  returns 0 on success; on error, the value of the semaphore is "
"left unchanged, -1 is returned, and I<errno> is set to indicate the error."
msgstr ""

#. type: TP
#: build/C/man3/sem_post.3:57
#, no-wrap
msgid "B<EOVERFLOW>"
msgstr ""

#.  Added in POSIX.1-2008 TC1 (Austin Interpretation 213)
#. type: Plain text
#: build/C/man3/sem_post.3:61
msgid "The maximum allowable value for a semaphore would be exceeded."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_post.3:67
msgid ""
"B<sem_post>()  is async-signal-safe: it may be safely called within a signal "
"handler."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_post.3:70
msgid "See B<sem_wait>(3)."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_post.3:74
msgid "B<sem_getvalue>(3), B<sem_wait>(3), B<sem_overview>(7)"
msgstr ""

#. type: TH
#: build/C/man3/sem_unlink.3:26
#, no-wrap
msgid "SEM_UNLINK"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_unlink.3:29
msgid "sem_unlink - remove a named semaphore"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_unlink.3:34
#, no-wrap
msgid "B<int sem_unlink(const char *>I<name>B<);>\n"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_unlink.3:44
msgid ""
"B<sem_unlink>()  removes the named semaphore referred to by I<name>.  The "
"semaphore name is removed immediately.  The semaphore is destroyed once all "
"other processes that have the semaphore open close it."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_unlink.3:50
msgid ""
"On success B<sem_unlink>()  returns 0; on error, -1 is returned, with "
"I<errno> set to indicate the error."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_unlink.3:54
msgid "The caller does not have permission to unlink this semaphore."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_unlink.3:62
msgid "There is no semaphore with the given I<name>."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_unlink.3:70
msgid ""
"B<sem_getvalue>(3), B<sem_open>(3), B<sem_post>(3), B<sem_wait>(3), "
"B<sem_overview>(7)"
msgstr ""

#. type: TH
#: build/C/man3/sem_wait.3:26
#, no-wrap
msgid "SEM_WAIT"
msgstr ""

#. type: TH
#: build/C/man3/sem_wait.3:26
#, no-wrap
msgid "2012-02-12"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:29
msgid "sem_wait, sem_timedwait, sem_trywait - lock a semaphore"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:34
#, no-wrap
msgid "B<int sem_wait(sem_t *>I<sem>B<);>\n"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:36
#, no-wrap
msgid "B<int sem_trywait(sem_t *>I<sem>B<);>\n"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:38
#, no-wrap
msgid ""
"B<int sem_timedwait(sem_t *>I<sem>B<, const struct timespec "
"*>I<abs_timeout>B<);>\n"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:45 build/C/man2/semop.2:51
msgid "Feature Test Macro Requirements for glibc (see B<feature_test_macros>(7)):"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:49
msgid ""
"B<sem_timedwait>(): _POSIX_C_SOURCE\\ E<gt>=\\ 200112L || _XOPEN_SOURCE\\ "
"E<gt>=\\ 600"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:59
msgid ""
"B<sem_wait>()  decrements (locks) the semaphore pointed to by I<sem>.  If "
"the semaphore's value is greater than zero, then the decrement proceeds, and "
"the function returns, immediately.  If the semaphore currently has the value "
"zero, then the call blocks until either it becomes possible to perform the "
"decrement (i.e., the semaphore value rises above zero), or a signal handler "
"interrupts the call."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:69
msgid ""
"B<sem_trywait>()  is the same as B<sem_wait>(), except that if the decrement "
"cannot be immediately performed, then call returns an error (I<errno> set to "
"B<EAGAIN>)  instead of blocking."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:82
msgid ""
"B<sem_timedwait>()  is the same as B<sem_wait>(), except that I<abs_timeout> "
"specifies a limit on the amount of time that the call should block if the "
"decrement cannot be immediately performed.  The I<abs_timeout> argument "
"points to a structure that specifies an absolute timeout in seconds and "
"nanoseconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC).  This "
"structure is defined as follows:"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:89
#, no-wrap
msgid ""
"struct timespec {\n"
"    time_t tv_sec;      /* Seconds */\n"
"    long   tv_nsec;     /* Nanoseconds [0 .. 999999999] */\n"
"};\n"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:100
msgid ""
"If the timeout has already expired by the time of the call, and the "
"semaphore could not be locked immediately, then B<sem_timedwait>()  fails "
"with a timeout error (I<errno> set to B<ETIMEDOUT>)."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:108
msgid ""
"If the operation can be performed immediately, then B<sem_timedwait>()  "
"never fails with a timeout error, regardless of the value of "
"I<abs_timeout>.  Furthermore, the validity of I<abs_timeout> is not checked "
"in this case."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:114
msgid ""
"All of these functions return 0 on success; on error, the value of the "
"semaphore is left unchanged, -1 is returned, and I<errno> is set to indicate "
"the error."
msgstr ""

#. type: TP
#: build/C/man3/sem_wait.3:115 build/C/man2/semop.2:363
#, no-wrap
msgid "B<EINTR>"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:119
msgid "The call was interrupted by a signal handler; see B<signal>(7)."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:126
msgid "The following additional error can occur for B<sem_trywait>():"
msgstr ""

#. type: TP
#: build/C/man3/sem_wait.3:126 build/C/man2/semop.2:338
#, no-wrap
msgid "B<EAGAIN>"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:130
msgid ""
"The operation could not be performed without blocking (i.e., the semaphore "
"currently has the value zero)."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:133
msgid "The following additional errors can occur for B<sem_timedwait>():"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:138
msgid ""
"The value of I<abs_timeout.tv_nsecs> is less than 0, or greater than or "
"equal to 1000 million."
msgstr ""

#. type: TP
#: build/C/man3/sem_wait.3:138
#, no-wrap
msgid "B<ETIMEDOUT>"
msgstr ""

#.  POSIX.1-2001 also allows EDEADLK -- "A deadlock condition
#.  was detected", but this does not occur on Linux(?).
#. type: Plain text
#: build/C/man3/sem_wait.3:143
msgid "The call timed out before the semaphore could be locked."
msgstr ""

#.  sem_wait() is always interrupted on most other implementations,
#.  but on FreeBSD 5.4 SA_RESTART does cause restarting.
#. type: Plain text
#: build/C/man3/sem_wait.3:153
msgid ""
"A signal handler always interrupts a blocked call to one of these functions, "
"regardless of the use of the B<sigaction>(2)  B<SA_RESTART> flag."
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:172
msgid ""
"The (somewhat trivial) program shown below operates on an unnamed "
"semaphore.  The program expects two command-line arguments.  The first "
"argument specifies a seconds value that is used to set an alarm timer to "
"generate a B<SIGALRM> signal.  This handler performs a B<sem_post>(3)  to "
"increment the semaphore that is being waited on in I<main()> using "
"B<sem_timedwait>().  The second command-line argument specifies the length "
"of the timeout, in seconds, for B<sem_timedwait>().  The following shows "
"what happens on two different runs of the program:"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:182
#, no-wrap
msgid ""
"$B< ./a.out 2 3>\n"
"About to call sem_timedwait()\n"
"sem_post() from handler\n"
"sem_timedwait() succeeded\n"
"$B< ./a.out 2 1>\n"
"About to call sem_timedwait()\n"
"sem_timedwait() timed out\n"
msgstr ""

#. type: SS
#: build/C/man3/sem_wait.3:184
#, no-wrap
msgid "Program source"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:195
#, no-wrap
msgid ""
"#include E<lt>unistd.hE<gt>\n"
"#include E<lt>stdio.hE<gt>\n"
"#include E<lt>stdlib.hE<gt>\n"
"#include E<lt>semaphore.hE<gt>\n"
"#include E<lt>time.hE<gt>\n"
"#include E<lt>assert.hE<gt>\n"
"#include E<lt>errno.hE<gt>\n"
"#include E<lt>signal.hE<gt>\n"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:197
#, no-wrap
msgid "sem_t sem;\n"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:200
#, no-wrap
msgid ""
"#define handle_error(msg) \\e\n"
"    do { perror(msg); exit(EXIT_FAILURE); } while (0)\n"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:210
#, no-wrap
msgid ""
"static void\n"
"handler(int sig)\n"
"{\n"
"    write(STDOUT_FILENO, \"sem_post() from handler\\en\", 24);\n"
"    if (sem_post(&sem) == -1) {\n"
"        write(STDERR_FILENO, \"sem_post() failed\\en\", 18);\n"
"        _exit(EXIT_FAILURE);\n"
"    }\n"
"}\n"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:217
#, no-wrap
msgid ""
"int\n"
"main(int argc, char *argv[])\n"
"{\n"
"    struct sigaction sa;\n"
"    struct timespec ts;\n"
"    int s;\n"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:223
#, no-wrap
msgid ""
"    if (argc != 3) {\n"
"        fprintf(stderr, \"Usage: %s E<lt>alarm-secsE<gt> "
"E<lt>wait-secsE<gt>\\en\",\n"
"                argv[0]);\n"
"        exit(EXIT_FAILURE);\n"
"    }\n"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:226
#, no-wrap
msgid ""
"    if (sem_init(&sem, 0, 0) == -1)\n"
"        handle_error(\"sem_init\");\n"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:228
#, no-wrap
msgid "    /* Establish SIGALRM handler; set alarm timer using argv[1] */\n"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:234
#, no-wrap
msgid ""
"    sa.sa_handler = handler;\n"
"    sigemptyset(&sa.sa_mask);\n"
"    sa.sa_flags = 0;\n"
"    if (sigaction(SIGALRM, &sa, NULL) == -1)\n"
"        handle_error(\"sigaction\");\n"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:236
#, no-wrap
msgid "    alarm(atoi(argv[1]));\n"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:239
#, no-wrap
msgid ""
"    /* Calculate relative interval as current time plus\n"
"       number of seconds given argv[2] */\n"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:242
#, no-wrap
msgid ""
"    if (clock_gettime(CLOCK_REALTIME, &ts) == -1)\n"
"        handle_error(\"clock_gettime\");\n"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:244
#, no-wrap
msgid "    ts.tv_sec += atoi(argv[2]);\n"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:248
#, no-wrap
msgid ""
"    printf(\"main() about to call sem_timedwait()\\en\");\n"
"    while ((s = sem_timedwait(&sem, &ts)) == -1 && errno == EINTR)\n"
"        continue;       /* Restart if interrupted by handler */\n"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:250
#, no-wrap
msgid "    /* Check what happened */\n"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:258
#, no-wrap
msgid ""
"    if (s == -1) {\n"
"        if (errno == ETIMEDOUT)\n"
"            printf(\"sem_timedwait() timed out\\en\");\n"
"        else\n"
"            perror(\"sem_timedwait\");\n"
"    } else\n"
"        printf(\"sem_timedwait() succeeded\\en\");\n"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:261
#, no-wrap
msgid ""
"    exit((s == 0) ? EXIT_SUCCESS : EXIT_FAILURE);\n"
"}\n"
msgstr ""

#. type: Plain text
#: build/C/man3/sem_wait.3:268
msgid ""
"B<clock_gettime>(2), B<sem_getvalue>(3), B<sem_post>(3), B<sem_overview>(7), "
"B<time>(7)"
msgstr ""

#. type: TH
#: build/C/man2/semctl.2:39
#, no-wrap
msgid "SEMCTL"
msgstr ""

#. type: TH
#: build/C/man2/semctl.2:39
#, no-wrap
msgid "2009-09-27"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:42
msgid "semctl - semaphore control operations"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:47 build/C/man2/semget.2:42 build/C/man2/semop.2:41
#, no-wrap
msgid ""
"B<#include E<lt>sys/types.hE<gt>>\n"
"B<#include E<lt>sys/ipc.hE<gt>>\n"
"B<#include E<lt>sys/sem.hE<gt>>\n"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:49
#, no-wrap
msgid "B<int semctl(int >I<semid>B<, int >I<semnum>B<, int >I<cmd>B<, ...);>\n"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:60
msgid ""
"B<semctl>()  performs the control operation specified by I<cmd> on the "
"semaphore set identified by I<semid>, or on the I<semnum>-th semaphore of "
"that set.  (The semaphores in a set are numbered starting at 0.)"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:66
msgid ""
"This function has three or four arguments, depending on I<cmd>.  When there "
"are four, the fourth has the type I<union semun>.  The I<calling program> "
"must define this union as follows:"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:76
#, no-wrap
msgid ""
"union semun {\n"
"    int              val;    /* Value for SETVAL */\n"
"    struct semid_ds *buf;    /* Buffer for IPC_STAT, IPC_SET */\n"
"    unsigned short  *array;  /* Array for GETALL, SETALL */\n"
"    struct seminfo  *__buf;  /* Buffer for IPC_INFO\n"
"                                (Linux-specific) */\n"
"};\n"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:82
msgid ""
"The I<semid_ds> data structure is defined in I<E<lt>sys/sem.hE<gt>> as "
"follows:"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:91
#, no-wrap
msgid ""
"struct semid_ds {\n"
"    struct ipc_perm sem_perm;  /* Ownership and permissions */\n"
"    time_t          sem_otime; /* Last semop time */\n"
"    time_t          sem_ctime; /* Last change time */\n"
"    unsigned short  sem_nsems; /* No. of semaphores in set */\n"
"};\n"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:99
msgid ""
"The I<ipc_perm> structure is defined in I<E<lt>sys/ipc.hE<gt>> as follows "
"(the highlighted fields are settable using B<IPC_SET>):"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:111
#, no-wrap
msgid ""
"struct ipc_perm {\n"
"    key_t          __key; /* Key supplied to semget(2) */\n"
"    uid_t          B<uid>;   /* Effective UID of owner */\n"
"    gid_t          B<gid>;   /* Effective GID of owner */\n"
"    uid_t          cuid;  /* Effective UID of creator */\n"
"    gid_t          cgid;  /* Effective GID of creator */\n"
"    unsigned short B<mode>;  /* Permissions */\n"
"    unsigned short __seq; /* Sequence number */\n"
"};\n"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:117
msgid "Valid values for I<cmd> are:"
msgstr ""

#. type: TP
#: build/C/man2/semctl.2:117
#, no-wrap
msgid "B<IPC_STAT>"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:129
msgid ""
"Copy information from the kernel data structure associated with I<semid> "
"into the I<semid_ds> structure pointed to by I<arg.buf>.  The argument "
"I<semnum> is ignored.  The calling process must have read permission on the "
"semaphore set."
msgstr ""

#. type: TP
#: build/C/man2/semctl.2:129
#, no-wrap
msgid "B<IPC_SET>"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:152
msgid ""
"Write the values of some members of the I<semid_ds> structure pointed to by "
"I<arg.buf> to the kernel data structure associated with this semaphore set, "
"updating also its I<sem_ctime> member.  The following members of the "
"structure are updated: I<sem_perm.uid>, I<sem_perm.gid>, and (the least "
"significant 9 bits of)  I<sem_perm.mode>.  The effective UID of the calling "
"process must match the owner (I<sem_perm.uid>)  or creator "
"(I<sem_perm.cuid>)  of the semaphore set, or the caller must be privileged.  "
"The argument I<semnum> is ignored."
msgstr ""

#. type: TP
#: build/C/man2/semctl.2:152
#, no-wrap
msgid "B<IPC_RMID>"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:167
msgid ""
"Immediately remove the semaphore set, awakening all processes blocked in "
"B<semop>(2)  calls on the set (with an error return and I<errno> set to "
"B<EIDRM>).  The effective user ID of the calling process must match the "
"creator or owner of the semaphore set, or the caller must be privileged.  "
"The argument I<semnum> is ignored."
msgstr ""

#. type: TP
#: build/C/man2/semctl.2:167
#, no-wrap
msgid "B<IPC_INFO> (Linux-specific)"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:179
msgid ""
"Returns information about system-wide semaphore limits and parameters in the "
"structure pointed to by I<arg.__buf>.  This structure is of type I<seminfo>, "
"defined in I<E<lt>sys/sem.hE<gt>> if the B<_GNU_SOURCE> feature test macro "
"is defined:"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:201
#, no-wrap
msgid ""
"struct  seminfo {\n"
"    int semmap;  /* Number of entries in semaphore\n"
"                    map; unused within kernel */\n"
"    int semmni;  /* Maximum number of semaphore sets */\n"
"    int semmns;  /* Maximum number of semaphores in all\n"
"                    semaphore sets */\n"
"    int semmnu;  /* System-wide maximum number of undo\n"
"                    structures; unused within kernel */\n"
"    int semmsl;  /* Maximum number of semaphores in a\n"
"                    set */\n"
"    int semopm;  /* Maximum number of operations for\n"
"                    semop(2) */\n"
"    int semume;  /* Maximum number of undo entries per\n"
"                    process; unused within kernel */\n"
"    int semusz;  /* Size of struct sem_undo */\n"
"    int semvmx;  /* Maximum semaphore value */\n"
"    int semaem;  /* Max. value that can be recorded for\n"
"                    semaphore adjustment (SEM_UNDO) */\n"
"};\n"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:215
msgid ""
"The I<semmsl>, I<semmns>, I<semopm>, and I<semmni> settings can be changed "
"via I</proc/sys/kernel/sem>; see B<proc>(5)  for details."
msgstr ""

#. type: TP
#: build/C/man2/semctl.2:215
#, no-wrap
msgid "B<SEM_INFO> (Linux-specific)"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:229
msgid ""
"Returns a I<seminfo> structure containing the same information as for "
"B<IPC_INFO>, except that the following fields are returned with information "
"about system resources consumed by semaphores: the I<semusz> field returns "
"the number of semaphore sets that currently exist on the system; and the "
"I<semaem> field returns the total number of semaphores in all semaphore sets "
"on the system."
msgstr ""

#. type: TP
#: build/C/man2/semctl.2:229
#, no-wrap
msgid "B<SEM_STAT> (Linux-specific)"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:240
msgid ""
"Returns a I<semid_ds> structure as for B<IPC_STAT>.  However, the I<semid> "
"argument is not a semaphore identifier, but instead an index into the "
"kernel's internal array that maintains information about all semaphore sets "
"on the system."
msgstr ""

#. type: TP
#: build/C/man2/semctl.2:240
#, no-wrap
msgid "B<GETALL>"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:251
msgid ""
"Return B<semval> (i.e., the current value)  for all semaphores of the set "
"into I<arg.array>.  The argument I<semnum> is ignored.  The calling process "
"must have read permission on the semaphore set."
msgstr ""

#. type: TP
#: build/C/man2/semctl.2:251 build/C/man2/semctl.2:349
#, no-wrap
msgid "B<GETNCNT>"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:264
msgid ""
"The system call returns the value of B<semncnt> for the I<semnum>-th "
"semaphore of the set (i.e., the number of processes waiting for an increase "
"of B<semval> for the I<semnum>-th semaphore of the set).  The calling "
"process must have read permission on the semaphore set."
msgstr ""

#. type: TP
#: build/C/man2/semctl.2:264 build/C/man2/semctl.2:353
#, no-wrap
msgid "B<GETPID>"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:277
msgid ""
"The system call returns the value of B<sempid> for the I<semnum>-th "
"semaphore of the set (i.e., the PID of the process that executed the last "
"B<semop>(2)  call for the I<semnum>-th semaphore of the set).  The calling "
"process must have read permission on the semaphore set."
msgstr ""

#. type: TP
#: build/C/man2/semctl.2:277 build/C/man2/semctl.2:357
#, no-wrap
msgid "B<GETVAL>"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:285
msgid ""
"The system call returns the value of B<semval> for the I<semnum>-th "
"semaphore of the set.  The calling process must have read permission on the "
"semaphore set."
msgstr ""

#. type: TP
#: build/C/man2/semctl.2:285 build/C/man2/semctl.2:361
#, no-wrap
msgid "B<GETZCNT>"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:298
msgid ""
"The system call returns the value of B<semzcnt> for the I<semnum>-th "
"semaphore of the set (i.e., the number of processes waiting for B<semval> of "
"the I<semnum>-th semaphore of the set to become 0).  The calling process "
"must have read permission on the semaphore set."
msgstr ""

#. type: TP
#: build/C/man2/semctl.2:298
#, no-wrap
msgid "B<SETALL>"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:320
msgid ""
"Set B<semval> for all semaphores of the set using I<arg.array>, updating "
"also the I<sem_ctime> member of the I<semid_ds> structure associated with "
"the set.  Undo entries (see B<semop>(2))  are cleared for altered semaphores "
"in all processes.  If the changes to semaphore values would permit blocked "
"B<semop>(2)  calls in other processes to proceed, then those processes are "
"woken up.  The argument I<semnum> is ignored.  The calling process must have "
"alter (write) permission on the semaphore set."
msgstr ""

#. type: TP
#: build/C/man2/semctl.2:320
#, no-wrap
msgid "B<SETVAL>"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:338
msgid ""
"Set the value of B<semval> to I<arg.val> for the I<semnum>-th semaphore of "
"the set, updating also the I<sem_ctime> member of the I<semid_ds> structure "
"associated with the set.  Undo entries are cleared for altered semaphores in "
"all processes.  If the changes to semaphore values would permit blocked "
"B<semop>(2)  calls in other processes to proceed, then those processes are "
"woken up.  The calling process must have alter permission on the semaphore "
"set."
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:345
msgid "On failure B<semctl>()  returns -1 with I<errno> indicating the error."
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:349
msgid ""
"Otherwise the system call returns a nonnegative value depending on I<cmd> as "
"follows:"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:353
msgid "the value of B<semncnt>."
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:357
msgid "the value of B<sempid>."
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:361
msgid "the value of B<semval>."
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:365
msgid "the value of B<semzcnt>."
msgstr ""

#. type: TP
#: build/C/man2/semctl.2:365
#, no-wrap
msgid "B<IPC_INFO>"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:373
msgid ""
"the index of the highest used entry in the kernel's internal array recording "
"information about all semaphore sets.  (This information can be used with "
"repeated B<SEM_STAT> operations to obtain information about all semaphore "
"sets on the system.)"
msgstr ""

#. type: TP
#: build/C/man2/semctl.2:373
#, no-wrap
msgid "B<SEM_INFO>"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:377
msgid "As for B<IPC_INFO>."
msgstr ""

#. type: TP
#: build/C/man2/semctl.2:377
#, no-wrap
msgid "B<SEM_STAT>"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:381
msgid "the identifier of the semaphore set whose index was given in I<semid>."
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:385
msgid "All other I<cmd> values return 0 on success."
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:389
msgid "On failure, I<errno> will be set to one of the following:"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:408
msgid ""
"The argument I<cmd> has one of the values B<GETALL>, B<GETPID>, B<GETVAL>, "
"B<GETNCNT>, B<GETZCNT>, B<IPC_STAT>, B<SEM_STAT>, B<SETALL>, or B<SETVAL> "
"and the calling process does not have the required permissions on the "
"semaphore set and does not have the B<CAP_IPC_OWNER> capability."
msgstr ""

#. type: TP
#: build/C/man2/semctl.2:408 build/C/man2/semop.2:347
#, no-wrap
msgid "B<EFAULT>"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:415
msgid "The address pointed to by I<arg.buf> or I<arg.array> isn't accessible."
msgstr ""

#. type: TP
#: build/C/man2/semctl.2:415 build/C/man2/semop.2:360
#, no-wrap
msgid "B<EIDRM>"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:418 build/C/man2/semop.2:363
msgid "The semaphore set was removed."
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:429
msgid ""
"Invalid value for I<cmd> or I<semid>.  Or: for a B<SEM_STAT> operation, the "
"index value specified in I<semid> referred to an array slot that is "
"currently unused."
msgstr ""

#. type: TP
#: build/C/man2/semctl.2:429
#, no-wrap
msgid "B<EPERM>"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:447
msgid ""
"The argument I<cmd> has the value B<IPC_SET> or B<IPC_RMID> but the "
"effective user ID of the calling process is not the creator (as found in "
"I<sem_perm.cuid>)  or the owner (as found in I<sem_perm.uid>)  of the "
"semaphore set, and the process does not have the B<CAP_SYS_ADMIN> "
"capability."
msgstr ""

#. type: TP
#: build/C/man2/semctl.2:447 build/C/man2/semop.2:382
#, no-wrap
msgid "B<ERANGE>"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:460
msgid ""
"The argument I<cmd> has the value B<SETALL> or B<SETVAL> and the value to "
"which B<semval> is to be set (for some semaphore of the set) is less than 0 "
"or greater than the implementation limit B<SEMVMX>."
msgstr ""

#.  SVr4 documents additional error conditions EINVAL, EFBIG, ENOSPC.
#. type: Plain text
#: build/C/man2/semctl.2:463 build/C/man2/semget.2:221 build/C/man2/semop.2:400
msgid "SVr4, POSIX.1-2001."
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:474
msgid ""
"The B<IPC_INFO>, B<SEM_STAT> and B<SEM_INFO> operations are used by the "
"B<ipcs>(1)  program to provide information on allocated resources.  In the "
"future these may modified or moved to a /proc file system interface."
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:487
msgid ""
"Various fields in a I<struct semid_ds> were typed as I<short> under Linux "
"2.2 and have become I<long> under Linux 2.4.  To take advantage of this, a "
"recompilation under glibc-2.1.91 or later should suffice.  (The kernel "
"distinguishes old and new calls by an B<IPC_64> flag in I<cmd>.)"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:496
msgid ""
"In some earlier versions of glibc, the I<semun> union was defined in "
"I<E<lt>sys/sem.hE<gt>>, but POSIX.1-2001 requires that the caller define "
"this union.  On versions of glibc where this union is I<not> defined, the "
"macro B<_SEM_SEMUN_UNDEFINED> is defined in I<E<lt>sys/sem.hE<gt>>."
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:500
msgid "The following system limit on semaphore sets affects a B<semctl>()  call:"
msgstr ""

#. type: TP
#: build/C/man2/semctl.2:500 build/C/man2/semop.2:446
#, no-wrap
msgid "B<SEMVMX>"
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:505
msgid "Maximum value for B<semval>: implementation dependent (32767)."
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:509
msgid ""
"For greater portability it is best to always call B<semctl>()  with four "
"arguments."
msgstr ""

#. type: Plain text
#: build/C/man2/semctl.2:516
msgid ""
"B<ipc>(2), B<semget>(2), B<semop>(2), B<capabilities>(7), "
"B<sem_overview>(7), B<svipc>(7)"
msgstr ""

#. type: TH
#: build/C/man2/semget.2:34
#, no-wrap
msgid "SEMGET"
msgstr ""

#. type: TH
#: build/C/man2/semget.2:34
#, no-wrap
msgid "2004-05-27"
msgstr ""

#. type: Plain text
#: build/C/man2/semget.2:37
msgid "semget - get a semaphore set identifier"
msgstr ""

#. type: Plain text
#: build/C/man2/semget.2:47
msgid "B<int semget(key_t >I<key>B<,> B<int >I<nsems>B<,> B<int >I<semflg>B<);>"
msgstr ""

#. type: Plain text
#: build/C/man2/semget.2:65
msgid ""
"The B<semget>()  system call returns the semaphore set identifier associated "
"with the argument I<key>.  A new set of I<nsems> semaphores is created if "
"I<key> has the value B<IPC_PRIVATE> or if no existing semaphore set is "
"associated with I<key> and B<IPC_CREAT> is specified in I<semflg>."
msgstr ""

#. type: Plain text
#: build/C/man2/semget.2:84
msgid ""
"If I<semflg> specifies both B<IPC_CREAT> and B<IPC_EXCL> and a semaphore set "
"already exists for I<key>, then B<semget>()  fails with I<errno> set to "
"B<EEXIST>.  (This is analogous to the effect of the combination B<O_CREAT | "
"O_EXCL> for B<open>(2).)"
msgstr ""

#. type: Plain text
#: build/C/man2/semget.2:97
msgid ""
"Upon creation, the least significant 9 bits of the argument I<semflg> define "
"the permissions (for owner, group and others)  for the semaphore set.  These "
"bits have the same format, and the same meaning, as the I<mode> argument of "
"B<open>(2)  (though the execute permissions are not meaningful for "
"semaphores, and write permissions mean permission to alter semaphore "
"values)."
msgstr ""

#.  In truth, every one of the many implementations that I've tested sets
#.  the values to zero, but I suppose there is/was some obscure
#.  implementation out there that does not.
#. type: Plain text
#: build/C/man2/semget.2:107
msgid ""
"The values of the semaphores in a newly created set are indeterminate.  "
"(POSIX.1-2001 is explicit on this point.)  Although Linux, like many other "
"implementations, initializes the semaphore values to 0, a portable "
"application cannot rely on this: it should explicitly initialize the "
"semaphores to the desired values."
msgstr ""

#. type: Plain text
#: build/C/man2/semget.2:115
msgid ""
"When creating a new semaphore set, B<semget>()  initializes the set's "
"associated data structure, I<semid_ds> (see B<semctl>(2)), as follows:"
msgstr ""

#. type: Plain text
#: build/C/man2/semget.2:120
msgid ""
"I<sem_perm.cuid> and I<sem_perm.uid> are set to the effective user ID of the "
"calling process."
msgstr ""

#. type: Plain text
#: build/C/man2/semget.2:125
msgid ""
"I<sem_perm.cgid> and I<sem_perm.gid> are set to the effective group ID of "
"the calling process."
msgstr ""

#. type: Plain text
#: build/C/man2/semget.2:130
msgid ""
"The least significant 9 bits of I<sem_perm.mode> are set to the least "
"significant 9 bits of I<semflg>."
msgstr ""

#. type: Plain text
#: build/C/man2/semget.2:134
msgid "I<sem_nsems> is set to the value of I<nsems>."
msgstr ""

#. type: Plain text
#: build/C/man2/semget.2:137
msgid "I<sem_otime> is set to 0."
msgstr ""

#. type: Plain text
#: build/C/man2/semget.2:140
msgid "I<sem_ctime> is set to the current time."
msgstr ""

#. type: Plain text
#: build/C/man2/semget.2:151
msgid ""
"The argument I<nsems> can be 0 (a don't care)  when a semaphore set is not "
"being created.  Otherwise I<nsems> must be greater than 0 and less than or "
"equal to the maximum number of semaphores per semaphore set (B<SEMMSL>)."
msgstr ""

#.  and a check is made to see if it is marked for destruction.
#. type: Plain text
#: build/C/man2/semget.2:155
msgid "If the semaphore set already exists, the permissions are verified."
msgstr ""

#. type: Plain text
#: build/C/man2/semget.2:161
msgid ""
"If successful, the return value will be the semaphore set identifier (a "
"nonnegative integer), otherwise -1 is returned, with I<errno> indicating the "
"error."
msgstr ""

#. type: Plain text
#: build/C/man2/semget.2:165
msgid "On failure I<errno> will be set to one of the following:"
msgstr ""

#. type: Plain text
#: build/C/man2/semget.2:173
msgid ""
"A semaphore set exists for I<key>, but the calling process does not have "
"permission to access the set, and does not have the B<CAP_IPC_OWNER> "
"capability."
msgstr ""

#.  .TP
#.  .B EIDRM
#.  The semaphore set is marked to be deleted.
#. type: Plain text
#: build/C/man2/semget.2:186
msgid ""
"A semaphore set exists for I<key> and I<semflg> specified both B<IPC_CREAT> "
"and B<IPC_EXCL>."
msgstr ""

#. type: Plain text
#: build/C/man2/semget.2:197
msgid ""
"I<nsems> is less than 0 or greater than the limit on the number of "
"semaphores per semaphore set (B<SEMMSL>), or a semaphore set corresponding "
"to I<key> already exists, and I<nsems> is larger than the number of "
"semaphores in that set."
msgstr ""

#. type: Plain text
#: build/C/man2/semget.2:205
msgid ""
"No semaphore set exists for I<key> and I<semflg> did not specify "
"B<IPC_CREAT>."
msgstr ""

#. type: Plain text
#: build/C/man2/semget.2:209
msgid ""
"A semaphore set has to be created but the system does not have enough memory "
"for the new data structure."
msgstr ""

#. type: TP
#: build/C/man2/semget.2:209
#, no-wrap
msgid "B<ENOSPC>"
msgstr ""

#. type: Plain text
#: build/C/man2/semget.2:217
msgid ""
"A semaphore set has to be created but the system limit for the maximum "
"number of semaphore sets (B<SEMMNI>), or the system wide maximum number of "
"semaphores (B<SEMMNS>), would be exceeded."
msgstr ""

#. type: Plain text
#: build/C/man2/semget.2:231
msgid ""
"B<IPC_PRIVATE> isn't a flag field but a I<key_t> type.  If this special "
"value is used for I<key>, the system call ignores everything but the least "
"significant 9 bits of I<semflg> and creates a new semaphore set (on "
"success)."
msgstr ""

#. type: Plain text
#: build/C/man2/semget.2:235
msgid ""
"The following limits on semaphore set resources affect the B<semget>()  "
"call:"
msgstr ""

#. type: TP
#: build/C/man2/semget.2:235
#, no-wrap
msgid "B<SEMMNI>"
msgstr ""

#.  This /proc file is not available in Linux 2.2 and earlier -- MTK
#. type: Plain text
#: build/C/man2/semget.2:241
msgid ""
"System wide maximum number of semaphore sets: policy dependent (on Linux, "
"this limit can be read and modified via the fourth field of "
"I</proc/sys/kernel/sem>)."
msgstr ""

#. type: TP
#: build/C/man2/semget.2:241
#, no-wrap
msgid "B<SEMMSL>"
msgstr ""

#. type: Plain text
#: build/C/man2/semget.2:246
msgid ""
"Maximum number of semaphores per semid: implementation dependent (on Linux, "
"this limit can be read and modified via the first field of "
"I</proc/sys/kernel/sem>)."
msgstr ""

#. type: TP
#: build/C/man2/semget.2:246
#, no-wrap
msgid "B<SEMMNS>"
msgstr ""

#. type: Plain text
#: build/C/man2/semget.2:254
msgid ""
"System wide maximum number of semaphores: policy dependent (on Linux, this "
"limit can be read and modified via the second field of "
"I</proc/sys/kernel/sem>).  Values greater than B<SEMMSL * SEMMNI> makes it "
"irrelevant."
msgstr ""

#. type: SH
#: build/C/man2/semget.2:254 build/C/man2/semop.2:458
#, no-wrap
msgid "BUGS"
msgstr ""

#. type: Plain text
#: build/C/man2/semget.2:260
msgid ""
"The name choice B<IPC_PRIVATE> was perhaps unfortunate, B<IPC_NEW> would "
"more clearly show its function."
msgstr ""

#.  In fact they are initialized to zero on Linux, but POSIX.1-2001
#.  does not specify this, and we can't portably rely on it.
#. type: Plain text
#: build/C/man2/semget.2:279
msgid ""
"The semaphores in a set are not initialized by B<semget>().  In order to "
"initialize the semaphores, B<semctl>(2)  must be used to perform a B<SETVAL> "
"or a B<SETALL> operation on the semaphore set.  (Where multiple peers do not "
"know who will be the first to initialize the set, checking for a nonzero "
"I<sem_otime> in the associated data structure retrieved by a B<semctl>(2)  "
"B<IPC_STAT> operation can be used to avoid races.)"
msgstr ""

#. type: Plain text
#: build/C/man2/semget.2:286
msgid ""
"B<semctl>(2), B<semop>(2), B<ftok>(3), B<capabilities>(7), "
"B<sem_overview>(7), B<svipc>(7)"
msgstr ""

#. type: TH
#: build/C/man2/semop.2:33
#, no-wrap
msgid "SEMOP"
msgstr ""

#. type: TH
#: build/C/man2/semop.2:33
#, no-wrap
msgid "2008-10-04"
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:36
msgid "semop, semtimedop - semaphore operations"
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:43
#, no-wrap
msgid ""
"B<int semop(int >I<semid>B<, struct sembuf *>I<sops>B<, unsigned "
">I<nsops>B<);>\n"
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:46
#, no-wrap
msgid ""
"B<int semtimedop(int >I<semid>B<, struct sembuf *>I<sops>B<, unsigned "
">I<nsops>B<,>\n"
"B<               struct timespec *>I<timeout>B<);>\n"
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:55
msgid "B<semtimedop>(): _GNU_SOURCE"
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:57
msgid "Each semaphore in a semaphore set has the following associated values:"
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:64
#, no-wrap
msgid ""
"unsigned short  semval;   /* semaphore value */\n"
"unsigned short  semzcnt;  /* # waiting for zero */\n"
"unsigned short  semncnt;  /* # waiting for increase */\n"
"pid_t           sempid;   /* process that did last op */\n"
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:78
msgid ""
"B<semop>()  performs operations on selected semaphores in the set indicated "
"by I<semid>.  Each of the I<nsops> elements in the array pointed to by "
"I<sops> specifies an operation to be performed on a single semaphore.  The "
"elements of this structure are of type I<struct sembuf>, containing the "
"following members:"
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:84
#, no-wrap
msgid ""
"unsigned short sem_num;  /* semaphore number */\n"
"short          sem_op;   /* semaphore operation */\n"
"short          sem_flg;  /* operation flags */\n"
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:96
msgid ""
"Flags recognized in I<sem_flg> are B<IPC_NOWAIT> and B<SEM_UNDO>.  If an "
"operation specifies B<SEM_UNDO>, it will be automatically undone when the "
"process terminates."
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:111
msgid ""
"The set of operations contained in I<sops> is performed in I<array order>, "
"and I<atomically>, that is, the operations are performed either as a "
"complete unit, or not at all.  The behavior of the system call if not all "
"operations can be performed immediately depends on the presence of the "
"B<IPC_NOWAIT> flag in the individual I<sem_flg> fields, as noted below."
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:118
msgid ""
"Each operation is performed on the I<sem_num>-th semaphore of the semaphore "
"set, where the first semaphore of the set is numbered 0.  There are three "
"types of operation, distinguished by the value of I<sem_op>."
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:131
msgid ""
"If I<sem_op> is a positive integer, the operation adds this value to the "
"semaphore value (I<semval>).  Furthermore, if B<SEM_UNDO> is specified for "
"this operation, the system updates the process undo count (I<semadj>)  for "
"this semaphore.  This operation can always proceed\\(emit never forces a "
"process to wait.  The calling process must have alter permission on the "
"semaphore set."
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:156
msgid ""
"If I<sem_op> is zero, the process must have read permission on the semaphore "
"set.  This is a \"wait-for-zero\" operation: if I<semval> is zero, the "
"operation can immediately proceed.  Otherwise, if B<IPC_NOWAIT> is specified "
"in I<sem_flg>, B<semop>()  fails with I<errno> set to B<EAGAIN> (and none of "
"the operations in I<sops> is performed).  Otherwise I<semzcnt> (the count of "
"processes waiting until this semaphore's value becomes zero)  is incremented "
"by one and the process sleeps until one of the following occurs:"
msgstr ""

#. type: IP
#: build/C/man2/semop.2:156 build/C/man2/semop.2:161 build/C/man2/semop.2:169 build/C/man2/semop.2:179 build/C/man2/semop.2:230 build/C/man2/semop.2:245 build/C/man2/semop.2:252 build/C/man2/semop.2:262
#, no-wrap
msgid "\\(bu"
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:161
msgid "I<semval> becomes 0, at which time the value of I<semzcnt> is decremented."
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:169
msgid ""
"The semaphore set is removed: B<semop>()  fails, with I<errno> set to "
"B<EIDRM>."
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:179
msgid ""
"The calling process catches a signal: the value of I<semzcnt> is decremented "
"and B<semop>()  fails, with I<errno> set to B<EINTR>."
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:190
msgid ""
"The time limit specified by I<timeout> in a B<semtimedop>()  call expires: "
"B<semop>()  fails, with I<errno> set to B<EAGAIN>."
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:230
msgid ""
"If I<sem_op> is less than zero, the process must have alter permission on "
"the semaphore set.  If I<semval> is greater than or equal to the absolute "
"value of I<sem_op>, the operation can proceed immediately: the absolute "
"value of I<sem_op> is subtracted from I<semval>, and, if B<SEM_UNDO> is "
"specified for this operation, the system updates the process undo count "
"(I<semadj>)  for this semaphore.  If the absolute value of I<sem_op> is "
"greater than I<semval>, and B<IPC_NOWAIT> is specified in I<sem_flg>, "
"B<semop>()  fails, with I<errno> set to B<EAGAIN> (and none of the "
"operations in I<sops> is performed).  Otherwise I<semncnt> (the counter of "
"processes waiting for this semaphore's value to increase)  is incremented by "
"one and the process sleeps until one of the following occurs:"
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:245
msgid ""
"I<semval> becomes greater than or equal to the absolute value of I<sem_op>, "
"at which time the value of I<semncnt> is decremented, the absolute value of "
"I<sem_op> is subtracted from I<semval> and, if B<SEM_UNDO> is specified for "
"this operation, the system updates the process undo count (I<semadj>)  for "
"this semaphore."
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:252
msgid ""
"The semaphore set is removed from the system: B<semop>()  fails, with "
"I<errno> set to B<EIDRM>."
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:262
msgid ""
"The calling process catches a signal: the value of I<semncnt> is decremented "
"and B<semop>()  fails, with I<errno> set to B<EINTR>."
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:271
msgid ""
"The time limit specified by I<timeout> in a B<semtimedop>()  call expires: "
"the system call fails, with I<errno> set to B<EAGAIN>."
msgstr ""

#.  and
#.  .I sem_ctime
#. type: Plain text
#: build/C/man2/semop.2:282
msgid ""
"On successful completion, the I<sempid> value for each semaphore specified "
"in the array pointed to by I<sops> is set to the process ID of the calling "
"process.  In addition, the I<sem_otime> is set to the current time."
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:309
msgid ""
"B<semtimedop>()  behaves identically to B<semop>()  except that in those "
"cases were the calling process would sleep, the duration of that sleep is "
"limited by the amount of elapsed time specified by the I<timespec> structure "
"whose address is passed in the I<timeout> argument.  If the specified time "
"limit has been reached, B<semtimedop>()  fails with I<errno> set to "
"B<EAGAIN> (and none of the operations in I<sops> is performed).  If the "
"I<timeout> argument is NULL, then B<semtimedop>()  behaves exactly like "
"B<semop>()."
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:319
msgid ""
"If successful B<semop>()  and B<semtimedop>()  return 0; otherwise they "
"return -1 with I<errno> indicating the error."
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:323
msgid "On failure, I<errno> is set to one of the following:"
msgstr ""

#. type: TP
#: build/C/man2/semop.2:323
#, no-wrap
msgid "B<E2BIG>"
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:331
msgid ""
"The argument I<nsops> is greater than B<SEMOPM>, the maximum number of "
"operations allowed per system call."
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:338
msgid ""
"The calling process does not have the permissions required to perform the "
"specified semaphore operations, and does not have the B<CAP_IPC_OWNER> "
"capability."
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:347
msgid ""
"An operation could not proceed immediately and either B<IPC_NOWAIT> was "
"specified in I<sem_flg> or the time limit specified in I<timeout> expired."
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:354
msgid ""
"An address specified in either the I<sops> or the I<timeout> argument isn't "
"accessible."
msgstr ""

#. type: TP
#: build/C/man2/semop.2:354
#, no-wrap
msgid "B<EFBIG>"
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:360
msgid ""
"For some operation the value of I<sem_num> is less than 0 or greater than or "
"equal to the number of semaphores in the set."
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:367
msgid ""
"While blocked in this system call, the process caught a signal; see "
"B<signal>(7)."
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:374
msgid ""
"The semaphore set doesn't exist, or I<semid> is less than zero, or I<nsops> "
"has a nonpositive value."
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:382
msgid ""
"The I<sem_flg> of some operation specified B<SEM_UNDO> and the system does "
"not have enough memory to allocate the undo structure."
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:390
msgid ""
"For some operation I<sem_op+semval> is greater than B<SEMVMX>, the "
"implementation dependent maximum value for I<semval>."
msgstr ""

#. type: SH
#: build/C/man2/semop.2:390
#, no-wrap
msgid "VERSIONS"
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:397
msgid ""
"B<semtimedop>()  first appeared in Linux 2.5.52, and was subsequently "
"backported into kernel 2.4.22.  Glibc support for B<semtimedop>()  first "
"appeared in version 2.3.3."
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:408
msgid ""
"The I<sem_undo> structures of a process aren't inherited by the child "
"produced by B<fork>(2), but they are inherited across an B<execve>(2)  "
"system call."
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:414
msgid ""
"B<semop>()  is never automatically restarted after being interrupted by a "
"signal handler, regardless of the setting of the B<SA_RESTART> flag when "
"establishing a signal handler."
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:429
msgid ""
"I<semadj> is a per-process integer which is simply the (negative) count of "
"all semaphore operations performed specifying the B<SEM_UNDO> flag.  When a "
"semaphore's value is directly set using the B<SETVAL> or B<SETALL> request "
"to B<semctl>(2), the corresponding I<semadj> values in all processes are "
"cleared."
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:434
msgid ""
"The I<semval>, I<sempid>, I<semzcnt>, and I<semnct> values for a semaphore "
"can all be retrieved using appropriate B<semctl>(2)  calls."
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:438
msgid "The following limits on semaphore set resources affect the B<semop>()  call:"
msgstr ""

#. type: TP
#: build/C/man2/semop.2:438
#, no-wrap
msgid "B<SEMOPM>"
msgstr ""

#.  This /proc file is not available in Linux 2.2 and earlier -- MTK
#. type: Plain text
#: build/C/man2/semop.2:446
msgid ""
"Maximum number of operations allowed for one B<semop>()  call (32)  (on "
"Linux, this limit can be read and modified via the third field of "
"I</proc/sys/kernel/sem>)."
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:451
msgid "Maximum allowable value for I<semval>: implementation dependent (32767)."
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:458
msgid ""
"The implementation has no intrinsic limits for the adjust on exit maximum "
"value (B<SEMAEM>), the system wide maximum number of undo structures "
"(B<SEMMNU>)  and the per-process maximum number of undo entries system "
"parameters."
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:479
msgid ""
"When a process terminates, its set of associated I<semadj> structures is "
"used to undo the effect of all of the semaphore operations it performed with "
"the B<SEM_UNDO> flag.  This raises a difficulty: if one (or more) of these "
"semaphore adjustments would result in an attempt to decrease a semaphore's "
"value below zero, what should an implementation do? One possible approach "
"would be to block until all the semaphore adjustments could be performed.  "
"This is however undesirable since it could force process termination to "
"block for arbitrarily long periods.  Another possibility is that such "
"semaphore adjustments could be ignored altogether (somewhat analogously to "
"failing when B<IPC_NOWAIT> is specified for a semaphore operation).  Linux "
"adopts a third approach: decreasing the semaphore value as far as possible "
"(i.e., to zero) and allowing process termination to proceed immediately."
msgstr ""

#.  The bug report:
#.  http://marc.theaimsgroup.com/?l=linux-kernel&m=110260821123863&w=2
#.  the fix:
#.  http://marc.theaimsgroup.com/?l=linux-kernel&m=110261701025794&w=2
#. type: Plain text
#: build/C/man2/semop.2:488
msgid ""
"In kernels 2.6.x, x E<lt>= 10, there is a bug that in some circumstances "
"prevents a process that is waiting for a semaphore value to become zero from "
"being woken up when the value does actually become zero.  This bug is fixed "
"in kernel 2.6.11."
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:493
msgid ""
"The following code segment uses B<semop>()  to atomically wait for the value "
"of semaphore 0 to become zero, and then increment the semaphore value by "
"one."
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:497
#, no-wrap
msgid ""
"    struct sembuf sops[2];\n"
"    int semid;\n"
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:499
#, no-wrap
msgid "    /* Code to set I<semid> omitted */\n"
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:503
#, no-wrap
msgid ""
"    sops[0].sem_num = 0;        /* Operate on semaphore 0 */\n"
"    sops[0].sem_op = 0;         /* Wait for value to equal 0 */\n"
"    sops[0].sem_flg = 0;\n"
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:507
#, no-wrap
msgid ""
"    sops[1].sem_num = 0;        /* Operate on semaphore 0 */\n"
"    sops[1].sem_op = 1;         /* Increment value by one */\n"
"    sops[1].sem_flg = 0;\n"
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:512
#, no-wrap
msgid ""
"    if (semop(semid, sops, 2) == -1) {\n"
"        perror(\"semop\");\n"
"        exit(EXIT_FAILURE);\n"
"    }\n"
msgstr ""

#. type: Plain text
#: build/C/man2/semop.2:521
msgid ""
"B<semctl>(2), B<semget>(2), B<sigaction>(2), B<capabilities>(7), "
"B<sem_overview>(7), B<svipc>(7), B<time>(7)"
msgstr ""
