ibm-information-center/dist/eclipse/plugins/i5OS.ic.apis_5.4.0.1/ipcsemun.htm

249 lines
6.3 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Copyright" content="Copyright (c) 2006 by IBM Corporation">
<title>sem_unlink()--Unlink Named Semaphore</title>
<!-- Begin Header Records -->
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<!-- Change History: -->
<!-- YYMMDD USERID Change description -->
<!-- Direct1 SCRIPT J converted by B2H R4.1 (346) (CMS) by V2KEA304 -->
<!-- at RCHVMW2 on 17 Feb 1999 at 11:05:09 -->
<!-- Edited by Kersten Feb 02 -->
<!-- This file has undergone html cleanup on 05/01/02 by JET -->
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
</head>
<body>
<!--End Header Records -->
<!-- Java sync-link -->
<script type="text/javascript" language="Javascript" src="../rzahg/synch.js">
</script>
<a name="Top_Of_Page"></a>
<h2>sem_unlink()--Unlink Named Semaphore</h2>
<div class="box" style="width: 60%;">
<br>
&nbsp;&nbsp;Syntax
<pre>
#include &lt;semaphore.h&gt;
int sem_unlink(const char *<em>name</em>);
</pre>
<br>
&nbsp;&nbsp;Service Program Name: QP0ZPSEM<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Default Public Authority: *USE<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Threadsafe: Yes<br>
<!-- iddvc RMBR -->
<br>
</div>
<p>The <strong>sem_unlink()</strong> function unlinks a named semaphore. The
name of the semaphore is removed from the set of names used by named
semaphores. If the semaphore is still in use, the semaphore is not deleted
until all processes using the semaphore have ended or have called <strong>
sem_close()</strong>. Using the name of an unlinked semaphore in subsequent
calls to <strong>sem_open()</strong> or <strong>sem_open_np()</strong> will
result in the creation of a new semaphore with the same name if the O_CREAT
flag of the <em>oflag</em> parameter has been set.</p>
<br>
<h3>Parameters</h3>
<dl>
<dt><strong>name</strong></dt>
<dd>(Input) A pointer to the null-terminated name of the semaphore to be
unlinked. The name should begin with a slash ('/') character. If the name does
not begin with a slash ('/') character, the system adds a slash to the
beginning of the name.
<p>This parameter is assumed to be represented in the coded character set
identifier (CCSID) currently in effect for the job. If the CCSID of the job is
65535, this parameter is assumed to be represented in the default CCSID of the
job.</p>
<p>The name is present in a set of names used only by named semaphores. The
name has no relation to any file system path names. The maximum length of the
name is SEM_NAME_MAX.</p>
<p>See <a href="ipcsemunu.htm">QlgSem_unlink()</a>--Unlink Named Semaphore
(using NLS-enabled path name) for a description and an example of supplying the
<em>name</em> in any CCSID.</p>
</dd>
</dl>
<br>
<h3>Authorities</h3>
<p><strong><a name="TBLASEMU1">Authorization required for
sem_unlink()</a></strong></p>
<table border cellpadding="5">
<!-- cols="60 20 20" -->
<tr>
<th align="left" valign="bottom">Object Referred to</th>
<th align="left" valign="bottom">Authority Required</th>
<th align="left" valign="bottom">errno</th>
</tr>
<tr>
<td align="left" valign="top">Named semaphore to be deleted</td>
<td align="left" valign="top">See note</td>
<td align="left" valign="top">EACCES</td>
</tr>
</table>
<p><strong>Note:</strong> To unlink a named semaphore, the effective UID of the
process must be the creator of the semaphore or the process must have *ALLOBJ
authority.</p>
<br>
<h3>Return Value</h3>
<table cellpadding="5">
<!-- cols="5 95" -->
<tr>
<td align="left" valign="top"><em>0</em></td>
<td align="left" valign="top"><strong>sem_unlink()</strong> was
successful.</td>
</tr>
<tr>
<td align="left" valign="top"><em>-1</em></td>
<td align="left" valign="top"><strong>sem_unlink()</strong> was not successful.
The <em>errno</em> variable is set to indicate the error.</td>
</tr>
</table>
<br>
<br>
<h3><a name="ecsemun">Error Conditions</a></h3>
<p>If <strong>sem_unlink()</strong> is not successful, <em>errno</em> usually
indicates one of the following errors. Under some conditions, <em>errno</em>
could indicate an error other than those listed here.</p>
<dl>
<dt><em>[EACCES]</em></dt>
<dd>
<p>Permission denied.</p>
<p>An attempt was made to access an object in a way forbidden by its object
access permissions.</p>
</dd>
<dt><em>[ENOENT]</em></dt>
<dd>
<p>No such path or directory.</p>
<p>The specified name doesnot refer to an existing named semaphore.</p>
</dd>
<dt><em>[EFAULT]</em></dt>
<dd>
<p>The address used for an argument is not correct.</p>
<p>In attempting to use an argument in a call, the system detected an address
that is not valid.</p>
<p>While attempting to access a parameter passed to this function, the system
detected an address that is not valid.</p>
</dd>
<dt><em>[ENAMETOOLONG]</em></dt>
<dd>
<p>The name is too long. The name is longer than the SEM_NAME_MAX
characters.</p>
</dd>
</dl>
<br>
<h3>Error Messages</h3>
<p>None.</p>
<br>
<h3><a name="risemun">Related Information</a></h3>
<ul>
<li>The &lt;<strong>semaphore.h</strong>&gt; file (see <a href="unix13.htm">
Header Files for UNIX-Type Functions</a>)<br>
<br>
</li>
<li><a href="ipcsemunu.htm">QlgSem_unlink()</a>--Unlink Named Semaphore (using
NLS-enabled path name)<br>
<br>
</li>
<li><a href="ipcsemo.htm">sem_open()</a>--Open Named Semaphore<br>
<br>
</li>
<li><a href="ipcsemon.htm">sem_open_np()</a>--Open Named Semaphore with Maximum
Value</li>
</ul>
<br>
<h3>Example</h3>
<p>See <a href="../apiref/aboutapis.htm#codedisclaimer">Code disclaimer information</a>
for information pertaining to code examples.</p>
<p>The following example unlinks the named semaphore "/mysem".</p>
<pre>
#include &lt;semaphore.h&gt;
main() {
int rc;
rc = sem_unlink("/mysem");
}
</pre>
<br>
<hr>
API introduced: V4R4
<hr>
<center>
<table cellpadding="2" cellspacing="2">
<tr align="center">
<td valign="middle" align="center"><a href="#Top_Of_Page">Top</a> | <a href=
"unix.htm">UNIX-Type APIs</a> | <a href="aplist.htm">APIs by category</a></td>
</tr>
</table>
</center>
</body>
</html>