Files
oldlinux-files/Ref-docs/syscalls/syscalls_78.html
2024-02-19 00:21:47 -05:00

62 lines
2.5 KiB
HTML

<html><!-- This HTML file has been created by texi2html 1.29
from syscalls.texi on 4 June 1994 -->
<TITLE>Syscall specifications of Linux - semget</TITLE>
<P>Go to the <A HREF="syscalls_77.html" tppabs="http://www.infran.ru/TechInfo/syscalls/syscalls_77.html">previous</A>, <A HREF="syscalls_79.html" tppabs="http://www.infran.ru/TechInfo/syscalls/syscalls_79.html">next</A> section.<P>
<H2><A NAME="SEC78" HREF="syscalls_toc.html#SEC78" tppabs="http://www.infran.ru/TechInfo/syscalls/syscalls_toc.html#SEC78">semget</A></H2>
<P>
<H3>SYNOPSIS</H3>
<P>
<CODE>int semget(key_t <VAR>key</VAR>, int <VAR>nsems</VAR>, int <VAR>semflg</VAR>);</CODE>
<H3>PARAMETERS</H3>
<P>
<VAR>key</VAR>: [in] the semaphore set identificator.
<P>
<VAR>nsems</VAR>: [in] the number of semaphore in the set.
<P>
<VAR>semflg</VAR>: [in] flags (see description).
<P>
<H3>DESCRIPTION</H3>
<P>
Gets a semaphore set identifier. If <VAR>key</VAR> is <CODE>IPC_PRIVATE</CODE>, a
new set is created. Otherwise, the result depends on the value of
<VAR>semflg</VAR>:
<P>
<DL COMPACT>
<DT><CODE>IPC_CREAT</CODE>
<DD>creates a new queue for the key if it does not already exist.
<P>
<DT><CODE>IPC_EXCL</CODE>
<DD>if there is already a existing queue associated with <VAR>key</VAR>, the call
fails.
</DL>
<P>
The 9 lower bits of <VAR>semflg</VAR> specify the permission bits of the new
set. They have the same layout and meaning as those for files.
However, the execute permissions are meaningless for sets.
<P>
When creating a set the system sets the appropriate parameters in the
<CODE>semid_ds</CODE> structure associated with the new set. When accessing
an already existing set, the system simply check if the set can be
accessed.
<P>
<H3>RETURN VALUE</H3>
<P>
On success, the call returns the new semaphore set identificator. On
error -1 is returned and <CODE>errno</CODE> is set to one of the following
values:
<P>
<UL>
<LI><CODE>EACCESS</CODE>: the task has no access permission to the set.
<LI><CODE>EEXIST</CODE>: <CODE>IPC_CREAT</CODE> and <CODE>IPC_EXCL</CODE> were specified
and the set already exists.
<LI><CODE>EIDRM</CODE>: the set no longer exists in the system.
<LI><CODE>ENOENT</CODE>: the set never existed.
<LI><CODE>ENOSPC</CODE>: the maximum number of semaphore sets for the system
has been reached.
<LI><CODE>ENOMEM</CODE>
</UL>
<P>
<P>Go to the <A HREF="syscalls_77.html" tppabs="http://www.infran.ru/TechInfo/syscalls/syscalls_77.html">previous</A>, <A HREF="syscalls_79.html" tppabs="http://www.infran.ru/TechInfo/syscalls/syscalls_79.html">next</A> section.<P>