194 lines
5.9 KiB
HTML
194 lines
5.9 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>QlgSem_open()--Open Named Semaphore (using NLS-enabled path
|
|
name)</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 -->
|
|
<!-- IPCSOU SCR A converted by B2H R4.1 (346) (CMS) by V2CDIJAB at -->
|
|
<!-- RCHVMW2 on 15 Sep 2000 at 11:27:55 -->
|
|
<!-- 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>QlgSem_open()--Open Named Semaphore (using NLS-enabled path name)</h2>
|
|
|
|
<div class="box" style="width: 80%;">
|
|
<br>
|
|
Syntax
|
|
|
|
<pre>
|
|
#include <semaphore.h>
|
|
#include <qlg.h>
|
|
|
|
sem_t * QlgSem_open(const Qlg_Path_Name_T *<em>name</em>,
|
|
int <em>oflag</em>, ...);
|
|
</pre>
|
|
|
|
<br>
|
|
Service Program Name: QP0ZPSEM<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
Default Public Authority: *USE<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
Threadsafe: Yes<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
</div>
|
|
|
|
<p>The <strong>QlgSem_open()</strong> function, like the <strong>
|
|
sem_open()</strong> function, opens a named semaphore and returns a semaphore
|
|
pointer that may be used on subsequent calls to <strong>sem_post()</strong>,
|
|
<strong>sem_post_np()</strong>, <strong>sem_wait()</strong>, <strong>
|
|
sem_wait_np()</strong>, <strong>sem_trywait()</strong>, <strong>
|
|
sem_getvalue()</strong>, and <strong>sem_close()</strong>. The <strong>
|
|
QlgSem_open()</strong> function takes a pointer to a Qlg_Path_Name_T structure,
|
|
while the <strong>sem_open()</strong> function takes a pointer to a character
|
|
string that is in the CCSID of the job.</p>
|
|
|
|
<p>Limited information on the <em>name</em> parameter is provided in this API.
|
|
For additional information on the <em>name</em> parameter and a discussion of
|
|
other parameters, authorities required, return values, and related information,
|
|
see <a href="ipcsemo.htm">sem_open()</a>--Open Named Semaphore.</p>
|
|
|
|
<br>
|
|
|
|
|
|
<h3>Parameters</h3>
|
|
|
|
<dl>
|
|
<dt><strong>name</strong></dt>
|
|
|
|
<dd>(Input) A pointer to a Qlg_Path_Name_T structure that contains a path name
|
|
or a pointer to a path name of the semaphore to be opened. For more information
|
|
on the Qlg_Path_Name_T structure, see <a href="../apiref/pns.htm">Path name
|
|
format</a>.</dd>
|
|
</dl>
|
|
|
|
<br>
|
|
|
|
|
|
<h3>Error Conditions</h3>
|
|
|
|
<p>If <strong>QlgSem_open()</strong> is not successful, <em>errno</em> usually
|
|
indicates the following error or one of the errors identified in <a href=
|
|
"ipcsemo.htm#ecsemo">sem_open()</a>--Open Named Semaphore.</p>
|
|
|
|
<dl compact>
|
|
<dt><em>[ECONVERT]</em></dt>
|
|
|
|
<dd>A conversion error for the parameter <em>name</em>.</dd>
|
|
</dl>
|
|
|
|
<br>
|
|
|
|
|
|
<h3>Related Information</h3>
|
|
|
|
<ul>
|
|
<li>The <<strong>qlg.h</strong>> file (see <a href="unix13.htm">Header
|
|
Files for UNIX-Type Functions</a>)<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="ipcsemo.htm">sem_open()</a>--Open Named Semaphore<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="ipcsemonu.htm">QlgSem_open_np()</a>--Open Named Semaphore with
|
|
Maximum Value (using NLS-enabled path name)<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="ipcsemunu.htm">QlgSem_unlink()</a>--Unlink Named Semaphore (using
|
|
NLS-enabled path name)</li>
|
|
</ul>
|
|
|
|
<p><strong>Note:</strong> All of the related information for <strong>
|
|
sem_open()</strong> applies to <strong>QlgSem_open()</strong>. See Related
|
|
Information in <a href="ipcsemo.htm#risemo">sem_open()</a>.</p>
|
|
|
|
<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 opens the named semaphore "/mysemaphore" and creates
|
|
the semaphore with an initial value of 10 if it does not already exist. If the
|
|
semaphore is created, the permissions are set such that only the current user
|
|
has access to the semaphore.</p>
|
|
|
|
<pre>
|
|
#include <semaphore.h>
|
|
#include <qlg.h>
|
|
main() {
|
|
|
|
sem_t * my_semaphore;
|
|
int rc;
|
|
|
|
#define mypath "/mysemaphore"
|
|
const char US_const[3]= "US";
|
|
const char Language_const[4]="ENU";
|
|
const char Path_Name_Del_const[2]= "/";
|
|
typedef struct pnstruct
|
|
{
|
|
Qlg_Path_Name_T qlg_struct;
|
|
char[100] pn; /* This size must be >= the path */
|
|
/* name length or be a pointer */
|
|
/* to the path name. */
|
|
|
|
};
|
|
struct pnstruct path;
|
|
|
|
/***************************************************************/
|
|
/* Initialize Qlg_Path_Name_T parameters */
|
|
/***************************************************************/
|
|
memset((void*)path name, 0x00, sizeof(struct pnstruct));
|
|
path.qlg_struct.CCSID = 37;
|
|
memcpy(path.qlg_struct.Country_ID,US_const,2);
|
|
memcpy(path.qlg_struct.Language_ID,Language_const,3);
|
|
path.qlg_struct.Path_Type = QLG_CHAR_SINGLE;
|
|
path.qlg_struct.Path_Length = sizeof(mypath)-1;
|
|
memcpy(path.qlg_struct.Path_Name_Delimiter,Path_Name_Del_const,1);
|
|
memcpy(path.pn,mypath,sizeof(mypath));
|
|
|
|
my_semaphore = QlgSem_open((Qlg_Path_Name_T *)path name,
|
|
O_CREAT, S_IRUSR | S_IWUSR, 10);
|
|
|
|
}
|
|
</pre>
|
|
|
|
<br>
|
|
<hr>
|
|
API introduced: V5R1
|
|
|
|
<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>
|
|
|