ISO/IEC 9945-1:1996
(Main)Information technology - Portable Operating System Interface (POSIX) - Part 1: System Application Program Interface (API) [C Language]
Information technology - Portable Operating System Interface (POSIX) - Part 1: System Application Program Interface (API) [C Language]
Is part of the POSIX series of standards for applications and user interfaces to open systems. It defines the applications interface to basic system services for input/output, file system access, and process management.
Technologies de l'information — Interface pour la portabilité des systèmes (POSIX) — Partie 1: Interface programme de systèmes d'application (API) [Langage C]
General Information
Relations
Frequently Asked Questions
ISO/IEC 9945-1:1996 is a standard published by the International Organization for Standardization (ISO). Its full title is "Information technology - Portable Operating System Interface (POSIX) - Part 1: System Application Program Interface (API) [C Language]". This standard covers: Is part of the POSIX series of standards for applications and user interfaces to open systems. It defines the applications interface to basic system services for input/output, file system access, and process management.
Is part of the POSIX series of standards for applications and user interfaces to open systems. It defines the applications interface to basic system services for input/output, file system access, and process management.
ISO/IEC 9945-1:1996 is classified under the following ICS (International Classification for Standards) categories: 35.060 - Languages used in information technology. The ICS classification helps identify the subject area and facilitates finding related standards.
ISO/IEC 9945-1:1996 has the following relationships with other standards: It is inter standard links to ISO/IEC 9945-3:2002, ISO/IEC 9945-1:2002, ISO/IEC 9945-1:1990, ISO/IEC 9945-2:2002, ISO/IEC 9945-4:2002. Understanding these relationships helps ensure you are using the most current and applicable version of the standard.
You can purchase ISO/IEC 9945-1:1996 directly from iTeh Standards. The document is available in PDF format and is delivered instantly after payment. Add the standard to your cart and complete the secure checkout process. iTeh Standards is an authorized distributor of ISO standards.
Standards Content (Sample)
INTERNATIONAL
ISO/IEC
STANDARD
9945-l
ANSI/IEEE
Std 1003.1
Second edition
1996-07-12
Information technology - Portable
Operating System Interface (POSlX@) -
Part 1:
System Application Program Interface (API)
[C Language]
Technologies de /‘information - Interface pour la portabilit6 des syst&mes
(POSIX@) -
Partie 7: Interface programme de systemes d’application (API) [Langage C]
Reference number
ISO/I EC 9945-l : 1996(E)
ANSI/IEEE
Std 1003.1, 1996 Edition
This page intentionally left blank
International Standard ISO/IEC 9945-l: 1996 (E)
IEEE Std 1003.1,1996 Edition
(Incorporating ANSI/IEEE Stds 1003.1-1990, 1003.113-1993,
1003.1c-1995, and 1003.li-1995)
Information technology-
Portable Operating System
Interface (POSIX@)-Part 1:
System Application Program
Interface (API) [C Language]
Sponsor
Portable Applications Standards Committee
of the
IEEE Computer Society
*g-e
b 8
Adopted as an International Standard by the
*-Jr,
International Organization for Standardization
H
and by the
International Electrotechnical Commission
w
- American National Standard
Published by
The Institute of Electrical and Electronics Engineers, Inc.
Abstract: This standard is part of the POSIX series of standards for applications
and user interfaces to open systems. It defines the applications interface to basic sys-
tem services for input/output, file system access, and process management. It also
defines a format for data interchange. When options specified in the Realtime Exten-
sion are included, the standard also defines interfaces appropriate for realtime appli-
cations. When options specified in the Threads Extension are included, the standard
also defines interfaces appropriate for multithreaded applications. This standard is
stated in terms of its C language binding.
Keywords: API, application portability, C (programming language), data processing,
information interchange, open systems, operating system, portable application,
POSIX, programming language, realtime, system configuration computer interface,
threads
POSIX is a registered trademark of the Institute of Electrical and Electronics Engineers, Inc.
Quote in 8.1.2.3 on Returns is taken from ANSI X3.159-1989, developed under the auspices of the Amer-
ican National Standards Accredited Committee X3 Technical Committee X3Jll.
The Institute of Electrical and Electronics Engineers, Inc.
345 East 47th Street, New York, NY 10017-2394, USA
Copyright 0 1996 by the
Institute of Electrical and Electronics Engineers, Inc.
All rights reserved. Published 1996.
Printed in the United States ofAmerica,
ISBN l-55937-573-6
No part of this publication may be reproduced in any form,
in an electronic retrieval system or otherwise,
without the prior written permission of the publisher.
12 July 1996
SH94352
IEEE Standards documents are developed within the Technical Committees of the
IEEE Societies and the Standards Coordinating Committees of the IEEE Standards
Board. Members of the committees serve voluntarily and without compensation. They
are not necessarily members of the Institute. The standards developed within IEEE
represent a consensus of the broad expertise on the subject within the Institute as
well as those activities outside of IEEE that have expressed an interest in participat-
ing in the development of the standard.
Use of an IEEE Standard is wholly voluntary. The existence of an IEEE Standard
does not imply that there are no other ways to produce, test, measure, purchase, mar-
ket, or provide other goods and services related to the scope of the IEEE Standard.
Furthermore, the viewpoint expressed at the time a standard is approved and issued
is subject to change brought about through developments in the state of the art and
comments received from users of the standard. Every IEEE Standard is subjected to
review at least every five years for revision or reaffirmation. When a document is
more than five years old and has not been reaffirmed, it is reasonable to conclude that
its contents, although still of some value, do not wholly reflect the present state of the
art. Users are cautioned to check to determine that they have the latest edition of any
IEEE Standard.
Comments for revision of IEEE Standards are welcome from any interested party,
regardless of membership affiliation with IEEE. Suggestions for changes in docu-
ments should be in the form of a proposed change of text, together with appropriate
supporting comments.
Interpretations: Occasionally questions may arise regarding the meaning of portions
of standards as they relate to specific applications. When the need for interpretations
is brought to the attention of IEEE, the Institute will initiate action to prepare appro-
priate responses. Since IEEE Standards represent a consensus of all concerned inter-
ests, it is important to ensure that any interpretation has also received the
concurrence of a balance of interests. For this reason IEEE and the members of its
technical committees are not able to provide an instant response to interpretation
requests except in those cases where the matter has previously received formal con-
sideration.
Comments on standards and requests for interpretations should be addressed to:
Secretary, IEEE Standards Board
445 Hoes Lane
P.O. Box 1331
Piscataway, NJ 08855433 1
USA
Note: Attention is called to the possibility that implementation of this standard
may require use of subject matter covered by patent rights. By publication of this
standard, no position is taken with respect to the existence or validity of any
patent rights in connection therewith. The IEEE shall not be responsible for iden-
tifying all patents for which a license may be required by an IEEE standard or for
conducting inquiries into the legal validity or scope of those patents that are
brought to its attention.
Authorization to photocopy portions of any individual standard for internal or personal use is
granted by the Institute of Electrical and Electronics Engineers, Inc., provided that the appro-
priate fee is paid to Copyright Clearance Center. To arrange for payment of licensing fee, please
contact Copyright Clearance Center, Customer Service, 222 Rosewood Drive, Danvers, MA
01923 USA; (508) 750-8400. Permission to photocopy portions of any individual standard for
educational classroom use can also be obtained through the Copyright Clearance Center.
Contents
PAGE
xi
Foreword . . . . . . . . . . . . . . . . . . . . . . .
xii
Introduction . . . . . . . . . . . . . . . . . . . . . .
xii
Organization of This Part ofISO/IEC 9945 . . . . . . . . . . .
xl11 l ‘*
Base Documents . . . . . . . . . . . . . . . . . . .
xl11 ‘**
Background . . . . . . . . . . . . . . . . . . . . .
Audience l l l l l l l l l l l l l l l l l l l l l l xiv
l Xiv
l l l l l l l l l l l l l l
Purpose
Related Standard’s Activities’ l l l l l l l l l l l l l l l xix
Sectionl~Generaleeeeeeeeeeeeeeeeeeee 1
l l l l l l l l l l l l l l l l
1.1 Scope
1.2 Normatiie kef’erekces l l l l l l l l l l l l l l l
1.3 Conformance l l l l l l l l l l l l l l l l l l l
Section 2: Terminology and General Requirements l l l l l l l l
2.1 Conventions l l l l l l l l l l l l l l l l l l l
l l l l l l l l l l l l l l l l l 12
2.2 Definitions
2.3 General Concepts l l l l l l l l l l l l l l l l l
2.4 ErrorNumbers l l l l l l l l l l l l l l l l l l
2.5 Primitive System Data Types l l l l l l l l l l l l l
2.6 Environment Description l l l l l l l l l l l l l l
2.7 C Language Definitions l l l l l l l l l l l l l l l
2.8 NumericalLimits l l l l l l l l l l l l l l l l l
2.9 Symbolic Constants l l l l l l l l l l l l l l l l
Section 3: Process Primitives l l l l l l l l l l l l l l l l
3.1 Process Creation and Execution l l l l l l l l l l l l
3.1.1 Process Creation l l l l l l l l l l l l l l l
3.1.2 ExecuteaFile l l l l l l l l l l l l l l l l
3.1.3 Register Fork Handlers l l l l l l l l l l l l
3.2 Process Termination l l l l l l l l l l l l l l l l
3.2.1 Wait for Process Termination l l l l l l l l l l
3.2.2 Terminate a Process l l l l l l l l l l l l l l
3.3 Signals l l l l l l l l l l l l l l l l l l l l l
3.3.1 Signal Concepts l l l l l l l l l l l l l l l
l l l l l l l l l l l 79
3.3.2 Send a Signal to a Process
l l l l l l l l 80
3.3.3 Manipulate Signal Sets
3.3.4 Examine and Change Signal Action l l l l l l l l l
3.3.5 Examine and Change Blocked Signals l l l l l l l
3.3.6 Examine Pending Signals l l l l l l l l l l l l
3.3.7 Wait for a Signal l l l l l l l l l l l l l l l
3.3.8 Synchronously Accept a Signal l l l l l l l l l l
ii
3.3.9 Queue a Signal to a Process l . l . l l l l l l l
3.3.10 Send a Signal to aThread l l l l l l l l l l . l
3.4 Timer Operations l l l l l l l l l l l l l l l l l 93
3.4.1 ScheduleAlarm l eeeeeeeeeeeeee 93
3.4.2 Suspend Process Execution l l l l l l l l l l l 94
3.4.3 Delay Process Execution l l l l l l l l l l l l 94
Section 4: Process Environment l l l l l l l l l l l l l l l
4.1 Process1dentification. 97
4.1.1 Get Process and Parent Process IDS l l l l l l l l
4.2 User Identification l l l l l l l l l l l l l l l l l 98
4.2.1 Get Real User, Effective User, Real Group, and Effective Group
l l l l l l l l l l l l 98
IDS
l l l l l l l l l l
4.2.2 Set User andeGroup 16s l
4.2.3 Get Supplementary Group ;Ds’ l l l l . l l l l l
4.2.4 Get User Name l l l l l l l l l l l l l l l
4.3 Process Groups l l l l l l l l l l l l l l l l l l
4.3.1 Get Process GroupID l l l l l l l l l l e l l
l l l l l l 103
4.3.2 Create Session and Set Process Group ID
4.3.3 Set Process Group ID for Job Control l l l l l l l l
4.4 System Identification l l l l l l l l l l l l l l l l
4.4.1 Get System Name l l l l l l l l l l l l l l
l l l l l l l l l l l l 106
l l l
4.5 Time
4.5.1 Get SystemTimk l l l l l l l l l l l l l l l
4.5.2 Get Process Times l l l l l l l l l l l l l l
4.6 Environment Variables l l l l l l . l l . l l l l .
4.6.1 Environment Access l l l l l l l l l l l l l l
4.7 Terminal Identification l l l l l l l l l l l l l l l
4.7.1 Generate Terminal Pathname l l l l l l l l l l
4.7.2 Determine Terminal Device Name l l l l l l l l l
4.8 Configurable System Variables l l l l l l l l l l l l
4.8.1 Get Configurable System Variables l l l l l l l l
Section 5: Files and Directories l l l l l l l l l l l l l l l
l l l l l l l l l l l 113
5.1 Directories
5.1.1 Format’of’oirectory Entries’ l l l l l l l l l l l
5.1.2 Directory Operations l l l l l l l l l l l l l
5.2 Working Directory l l l l l l l l l l l l l l l l l
5.2.1 Change Current Working Directory l l l l l l l l
5.2.2 Get Working Directory Pathname l l l l l l l l l
5.3 General File Creation l l l l l l l l l l l . l l l l
5.3.1 Open aFile l l l l l l l l l l l l l l l l l
5.3.2 Create a New File or Rewrite an Existing One l l l . l
5.3.3 Set File Creation Mask l l l l l l l l l l l l l
5.3.4 Link to a File l l l l l l l l . l l l l . l l
5.4 Special File Creation l l l l l l l l l l l l . l l l
5.4.1 Make a Directory l l l l l l l l l l l l l l l
5.4.2 Make a FIFO Special File l l l l l l l l l l l l
5.5 File Removal l l l l l l l l l l l l l e l l l l l
5.5.1 Remove Directory Entries l l l l l l l l l l l l
. . .
5.5.2 Remove a Directory . . . . . . . . . . . . . . 129
5.5.3 Rename a File . l . . . . . . . . . . . . . . 130
5.6 File Characteristics l l l l 132
5.6.1 File Character&i& ieider and ‘Data Str’ucture l l l l 132
5.6.2 Get File Status l l l l l l l l l l l l 134
5.6.3 Check File Accessibility l l l l l l l l l l l l l 136
5.6.4 Change File Modes l l l l l l l l l l l l l l 137
5.6.5 Change Owner and Group of a File l l l l l l l 139
5.6.6 Set File Access and Modification Times’ l l l l l l l 140
5.6.7 Truncate a File to a Specified Length l l l l l l l l 142
5.7 Configurable Pathname Variables l l l l l l l 143
5.7.1 Get Configurable Pathname Variables l l l l l l l l 143
Section 6: Input and Output Primitives l l l l l l l l l l l l 147
l l l l l l l l l 147
6.1 Pipes
6.1.1 Create an !Inte&roce’ss Channel l l l l l l l l l l 147
l l 148
6.2 File Descriptor Manipulation l l l l l l l l l l l
l l 148
6.2.1 Duplicate an Open File Descriptor l l l l l l l
6.3 File Descriptor Deassignment l l l l l l l l l l l l l 149
6.3.1 Close a File l l l l l l l l l l l l l l l l l 149
l l 151
6.4 Input and Output l l l l l l l l l l l l l l l
l l 151
6.4.1 Read from a File l l l l l l l l l l l l l
l l 153
6.4.2 Write to a File l l l l l l l l l l l l l l
l l 156
6.5 Control Operations on Files l l l l l l l l l l l l
6.5.1 Data Definitions for File Control Operations l l l l l 156
6.5.2 File Control l l l l l l l l l 156
6.5.3 Reposition Readlw;it;! Filebffset l l l l l l l l l 161
l l 163
6.6 File Synchronization l l l l l l l l l l l l l l
6.6.1 Synchronize the State of a File l l l l l l l l l l 163
l l 164
6.6.2 Synchronize the Data of a File l l l l l l l l
l l 165
6.7 Asynchronous Input and Output l l l l l l l l l l
6.7.1 Data Definitions for Asynchronous Input and Output l l 165
l l 168
6.7.2 Asynchronous Read l l l l l l l l l l l l
l l 170
6.7.3 Asynchronous Write l l l l l l l l l l l l
l l 172
6.7.4 List Directed I/O l l l l l l l l l l l l l
6.7.5 Retrieve Error Status of Asynchronous I/O Operation l l
6.7.6 Retrieve Return Status of Asynchronous I/O Operation l l 176
6.7.7 Cancel Asynchronous I/O Request l l l l l l l l l 177
l l l l l l l l 178
6.7.8 Wait for Asynchronous I/O Request
l l 180
6.7.9 Asynchronous File Synchronization l l l l l l
Section 7: Device- and Class-Specific Functions l l l l l l l l l l
7.1 General Terminal Interface l l l l l l l l l l l l l l
7.1.1 Interface Characteristics l l l l l l l l l l l l
7.1.1.1 Opening a Terminal Device File l l l l l l
7.1.1.2 Process Groups l l l l l l l l l l l l
7.1.1.3 The Controlling Terminal l l l l l l l l l
7.1.1.4 Terminal Access Control l l l l l l l l l
7.1.1.5 Input Processing and Reading Data l l l l l
7.1.1.6 Canonical Mode Input Processing l l l l l l
iv
7.1.1.7 Noncanonical Mode Input Processing l l l l l
7.1.1.8 Writing Data and Output Processing l l l l l
7.1.1.9 Special Characters l l l l l l l l l l l
7.1.1.10 Modem Disconnect l l l l l l l l l l l
7.1.1.11 Closing a Terminal Device File l l l l l l l
7.1.2 Parameters That Can Be Set l l l l l l l l l l l
7.1.2.1 termios Structure l l l l l l l l l l l
7.1.2.2 Input Modes l l l l l l l l l l l l l
7.1.2.3 Output Modes l l l l l l l l l l l l
7.1.2.4 Control Modes l l l l l l l l l l l l
7.1.2.5 Local Modes l l l l l l l l l l l l l
7.1.2.6 Special Control Characters l l l l l l l l
7.1.2.7 Baud RateValues l l l l l l l l l l l
7.1.3 Baud Rate Functions l l l l l l l l l l l l l
7.1.3.1 Synopsis l l l l l l l l l l l l l l
7.1.3.2 Description l l l l l l l l l l l l l
7.1.3.3 Returns l l l l l l l l l l l l l l l
l l l l l l l l l l l l 196
7.1.3.4 Errors
l l l l l l l
7.1.3.5 Cross-References l
7.2 General Terminal Interface Control Functions’ l l l l l l l
l l l l l l l l l l l l 197
Get and Set State l
7.2.1
l l l l l l l l l 199
7.2.2 Line Control Functions l
7.2.3 Get Foreground Process Group 1; l l l l l l l l l
7.2.4 Set Foreground Process Group ID l l l l l l l l l
l 205
Section 8: Language-Specific Services for the C Programming Language
8.1 Referenced C Language Routines l l l l l l l l l l l l
l l l l l l l l l 206
8.1.1 Extensions to Time Functions
8.1.2 Extensions to setZocaZe() Function l l l l l l l l l
8.2 C Language Input/Output Functions l l l l l l l l l l
8.2.1 Map a Stream Pointer to a File Descriptor l l l l l l
8.2.2 Open a Stream on a File Descriptor l l l l l l l l
8.2.3 Interactions of Other FILE-Type C Functions l l l l l
8.2.4 Operations on Files - the remove () Function l l l l l
8.2.5 Temporary File Name - the tmpnam() Function l l l l
8.2.6 Stdio Locking Functions l l l l l l l l l l l l
8.2.7 Stdio With Explicit Client Locking l l l l l l w l l
8.3 Other C Language Functions l l l l l l l l l l l l l
8.3.1 Nonlocal Jumps l l l l l l l l l l l l l l l
8.3.2 Set Time Zone l l l l l l l l l l l l l l l l
8.3.3 Find String Token l l l l l l l l l l l l l l
8.3.4 ASCII Time Representation l l l l l l l l l l l
8.3.5 Current Time Representation l l l l l l l l l l
8.3.6 Coordinated Universal Time l l l l l l l l l l l
8.3.7 LocalTime l l l l l l l l l l l l l l l l l
8.3.8 Pseudo-Random Sequence Generation Functions l l l l
Section 9: System Databases l l l l l l l l l l l l l l l l
9.1 System Databases l l l l l l l l l l l l l l l l l
9.2 Database Access l l l l l l l l l l l l l l l l l
9.2.1 Group Database Access l l l l l l l l l l l l 226
9.2.2 User Database Access l l l l l l l l l l l l l 227
Section 10: Data Interchange Format l l l l l l l l l l l l l 231
10.1 Archive/Interchange File Format l l l l l l l l l l l l 231
10.1.1 Extended tar Format l l l l l l l l l l l l l 231
10.1.2 Extended cpio Format l l l l l l l l l l l l 235
10.1.3 Multiple Volumes l l l l l l l l l l l l l l 239
l
Section 11: Synchronization l l l l l l l l l l l l l 241
11.1 Semaphore Characteristics l l l l l l l l l l l l l l 241
11.2 Semaphore Functions l l l l l l l l l l l l l l l l 241
11.2.1 Initialize an Unnamed Semaphore l l l l l l l l l
11.2.2 Destroy an Unnamed Semaphore l l l l l l l l l 243
11.2.3 Initialize/Open a Named Semaphore l l l l l l l l 244
11.2.4 Close a Named Semaphore l l l l l l l l l l l 246
11.2.5 RemoveaNamed Semaphore l l l l l l l l l l 247
11.2.6 Locka Semaphore l l l l l l l l l l l l l l 248
l
11.2.7 Unlock a Semaphore l l l l l l l l l 250
11.2.8 Get thevalue of a Semaphore’ l l l l l l l l l l 251
11.3 Mutexes l l l l l l l l l l 252
11.3.1 Mu&x Initiahza’tioh Attributes l l l l l l l l 253
11.3.2 Initializing and Destroying a Mutex’ l l l l l l l l 255
l l l l l l l l l
11.3.3 Locking and Unlocking a Mutex 257
11.4 Condition Variables l l l l l 259
l l l l
11.4.1 Condition Variable’In~tializ’atibn Attributes l 259
11.4.2 Initializing and Destroying Condition Variables’ l l l l 261
11.4.3 Broadcasting and Signaling a Condition l l l l l l l 263
11.4.4 Waiting on a Condition l l l l l l l l l l l l l 264
Section 12: Memory Management l l l l l l l l l l l l l l 267
12.1 Memory Locking Functions l l l l l l l l l l l l l l 268
12.1.1 Lock/Unlock the Address Space of a Process l l l l 268
12.1.2 Lock/Unlock a Range of Process Address Space l l l l l 270
12.2 Memory Mapping Functions l l l l l 272
12.2.1 Map Process Addresses tb a’ M’embr; Object l l l l l l 272
12.2.2 Unmap Previously Mapped Addresses l l l l l l l 276
12.2.3 Change Memory Protection l l l l l l l l l l l 277
12.2.4 Memory Object Synchronization l l l l l l l l l 279
12.3 Shared Memory Functions l l l l l l l l l l l l l l 281
12.3.1 Open a Shared Memory Object l l l l l l l l l l 281
12.3.2 Remove a Shared Memory Object l l l l l l l l l
Section 13: Execution Scheduling l l l l l l l l l l l l l l 287
13.1 Scheduling Parameters l l l l l l l l l l l l l l l 287
13.2 Scheduling Policies l l l l l l l l l l l l l l l l 287
13.2.1 SCHED FIFO l l l l l l l l l l l l l l l l 288
l l l l l l l l l l l l
13.2.2 SCHED-RR l l l 289
.
l l l l l l l l l
13.2.3 SCHED-OTHER l l l l l 289
13.3 Process Scheduling Functions l l l l l l l l l l l l l
vi
13.3.1 Set Scheduling Parameters l l l l l l l l l l l
13.3.2 Get Scheduling Parameters l l l l l l l l l l l
l l l 293
13.3.3 Set Scheduling Policy and Scheduling Parameters
13.3.4 Get Scheduling Policy l l l l l l l l l l l l l
13.3.5 Yield Processor l l l l l l l l l l l l l l l
13.3.6 Get Scheduling Parameter Limits l l l l l l l l l
13.4 Thread Scheduling l l l l l l l l l l l l l l l l l
13.4.1 Thread Scheduling Attributes l l l l l l l l l l
13.4.2 Scheduling Contention Scope l l l l l l l l l l
13.4.3 Scheduling Allocation Domain l l l l l l l l l l
13.4.4 Scheduling Documentation l l l l l l l l l l l
13.5 Thread Scheduling Functions l l l l l l l l l l l l l
13.5.1 Thread Creation Scheduling Attributes l l l l l l l
13.5.2 Dynamic Thread Scheduling Parameters Access l l l l
l 304
l l l l l
13.6 Synchronization Scheduling
13.6.1 Mutex Initialization Scheduling Attribute’s l l l l l l
13.6.2 Change the Priority Ceiling of a Mutex l l l l l l l
l l l l l l l l l l 309
Section 14: Clocks and Timers
l l l 309
l l l l
14.1 Data Definitions for Clocks ahdeTimers l l l
l 309
l l l l l l l
14.1.1 Time Value Specification Structures
l 310
l l l l l l
14.1.2 Timer Event Notification Control Block
l l l 310
l l l l
14.1.3 Type Definitions l l l l l l l l
l 310
l l l l l l
14.1.4 Manifest Constants l l l l l l l
l 311
l l l l l l
14.2 Clock and Timer Functions l l l l l l l
l l l l l 311
l l l l l l
14.2.1 Clocks
l 312
l l l l l l
14.2.2 Create a Per:Process ‘&rner’ l l l l
l 314
l l l l l l
14.2.3 Delete a Per-Process Timer l l l l
l l l l l l l
14.2.4 Per-Process Timers l l l l l l l
l l l l l l l 317
14.2.5 High Resolution Sleep l l l l l l
Section 15: Message Passing l l l l l l l l l l l l l l l l
15.1 Data Definitions for Message Queues l l l l l l l l l l
15.1.1 Data Structures l l l l l l l l l l l l l l l
15.2 Message Passing Functions l l l l l l l l l l l l l l
15.2.1 Open aMessage Queue l l l l l l l l l l l l
15.2.2 Close a Message Queue l l l l l l l l l l l l
15.2.3 Remove a Message Queue l l l l l l l l l l l l
15.2.4 Send a Message to a Message Queue l l l l l l l l
15.2.5 Receive a Message From a Message Queue l l l l l l
l
15.2.6 Notify Process That a Message is Available on a Queue
15.2.7 Set Message Queue Attributes l l l l l l l l l l
15.2.8 Get Message Queue Attributes l l l l l l l l l l
Section 16: Thread Management l l l l l l l l l l l l l l l
l l l l l l l l 333
l l l l l l l l l
16.1 Threads
l l l l l l l l l l l 333
16.2 Thread Functions’
16.2.1 Thread Creation Attributes’ l l l l l l l l l l l
l l l l l l l l l l l l l l l
16.2.2 Thread Creation
16.2.3 Wait for Thread Termination l l l l l l l l l l
vii
16.2.4 Detaching a Thread l l l l l l l l l l l l l l 338
16.2.5 Thread Termination l l l l l l l l l l l l l l 339
16.2.6 Get ThreadID l l l l l l l l l l l l l l l l 340
16.2.7 Compare Thread IDS l l l l l l l l l l 341
16.2.8 Dynamic Package Initializa’tioh l l l l l l l l l l
Section 17: Thread-Specific Data l l l l l l l l l l l l l l l 343
17.1 Thread-Specific Data Functions l l l l l l l l l 343
17.1.1 Thread-Specific Data Key Creation l l l l l l l l 343
17.1.2 Thread-Specific Data Management l l l l l l l l
17.1.3 Thread-Specific Data Key Deletion l l l l l l l l l
Section 18: Thread Cancellation l l l l l l l l l l l l l l 347
18.1 Thread Cancellation Over-vie; l l l l l l l l l l l l l 347
18.1.1 Cancelability States l l l l l l l l l l l l l l 347
18.1.2 Cancellation Points l l l l l l l l l l l l l l 348
18.1.3 Thread Cancellation Cleanup Handlers l l l l l l l 349
18.1.4 Async-Cancel Safety l l l l l l l l l l l l l l 349
18.2 Thread Cancellation Functions l l l l l l l l l l l l 350
18.2.1 Canceling Execution of a Thread l l l l l l l l l 350
18.2.2 Setting Cancelability State l l l l l l l l 351
18.2.3 Establishing Cancellation Handlers l l l l l l l 352
18.3 Language-Independent Cancellation Functionality l l l l l l 353
18.3.1 Requesting Cancellation l l l l l l l l l l l l 353
18.3.2 Associating Cleanup Code With SCOPES l l l l l l l 353
18.3.3 Controlling Cancellation Within Scopes l l l l l l l 354
18.3.4 Defined Cancellation Sequence l l l l l l l l l l 354
18.3.5 List of Cancellation Points l l l l l l l l l l l 354
l
Annex A (informative) Bibliography l l l l l l l l l l l 355
A.1 Related Open Systems Standards l l l l l l l l l l l 355
A.2 Other Standards l l l l l l 357
A.3 Historical Documentation l and IhtrbductoryeTexts l l l l l l 358
A.4 Other Sources of Information l l l l l l l l l l l l l 360
Annex B (informative) Rationale and Notes l l l l l l l l l l l 361
B. 1 Scope and Normative Cross-References l l l l l l l l l l 361
B.2 Definitions and General Requirements l l l l l l l l l l 373
B.3 Process Primitives l l l l l l l l l l l l l l l l l 413
B.4 Process Environment l l l l l l l l l l l l l l l l 446
B.5 Files and Directories l l l l l l l l l l l l l l l l 453
B.6 Input and Output Primitives l l l l l l l l l l l l l
B .7 Device- and Class-Specific Functions l l
B.8 Language-Specific Services for the C P’gramming Language l l 492
B.9 System Databases l l l l l w l l l l l l l l l l l 504
B.10 Data Interchange Format l l l l l l l l l l l l l l
l
B. 11 Synchronization l l l l l l l l l l l l l l 512
B.12 Memory Management l l l l l l l l l l l l l l l :
B.13 Execution Scheduling l l l l l l l l l l l l l l l l
B.14 Clocks andTimers l l l l l l l l l l l l l l l l l 552
. . .
Vlll
B.15 Message Passing l l l l l l l l l l l l l l l l l
B.16 Thread Management l l l l l l l l l l l l l l l l
B.17 Thread-Specific Data l l l l l l l l l l l l l l l l
B.18 Thread Cancellation l l l l l l l l l l l l l l l l
Annex C (informative) Header Contents Samples l l l l l l l l l
Annex D (informative) Profiles l l l l l l l l l l l l l l l
l l l l l 607
l l l l l
D. 1 Definitions
D.2 Options in This Pardof;S;)/I&9945 l l l l l l l l l l l
D.3 Related Standards l l l l l l l l l l l l l l l l l
D.4 Related Activities l l l l l l l l l l l l l l l l l
D.5 Relationship to IEEE Std 1003.0-1995 l l l l l l l l l i
Annex E (informative) Sample National Profile l l l l l l l l l
E. 1 (Example) Profile for Denmark l l l l l l l l l l l l
Annex F (informative) Portability Considerations l l l l l l l l l
F.l User Requirements l l l l l l l l l l l l l l l l
F.2 Portability Capabilities l l l l l l l l l l l l l l l
F.3 Profiling Considerations l l l l l l e l l l l l l l l
Annex G (informative) Performance Metrics l l l l l l l l l l l
G.l Performance Measurement Documentation l l l l l l l l
G.2 Signals l l l l l l l l l l l l l l l l l l l l l
G.3 Synchronized Input and Output l l l l l l l l l l l l
G.4 Asynchronous Input and Output l l l l l l l l l l l l
G.5 Semaphores l l l l l l l l l l l l l l l l l l l
G.6 Mutexes and Condition Variables l l l l l l l l l l l l
G.7 Process Memory Locking l l l l l l l l l l l l l l l
G.8 SharedMemory l l l l l l l l l l l l l l l l l l
G.9 Execution Scheduling l l l l l l l l l l l l l l l l
G.10 Clocks and Timers l l l l l l l l l l l l l l l l l
G.11 Message Passing l l l l l l l l l l l l l l l l l
G.12 Thread Management l l l l l l l l l l l l l l l l
G.13 Thread Cancellation l l l l l l l l l l l l l l l l
Annex H (informative) Realtime Files l l l l l l l l l l l l l
H.l Data Definitions for Realtime Files l l l l l l l l l l l
H.2 Realtime File Functions l l l l l l l l l l l l l l l
H.3 Realtime Files l l l l l l l l l l l l l l l l l l
H.4 Rationale for Realtime Files l l l l l l l l l l l l l
H.5 Realtime File Functions l l l l l l l l l l l l l l l
Identifier Index l l l l l l l l l l l l l l l l l l l l l
Alphabetic Topical Index l l l l l l l l l l l l l l l l l l
iX
TABLES
-
Table 2-l Primitive System Data Types l l l l l l l l l l 38
-
Table 2-2 Reserved Header Symbols l l l l l l l l l l l l 42
-
Table 2-3 MinimumValues l l l l l l l l l l l l l l l 48
-
Table 2-4 Run-Time Increasable Values l l 49
-
l l
Table 2-5 Run-Time Invariant Values (Possibly Indeterminate) l 50
-
Pathname Variable Values l l l l l l l l l l l 51
Table 2-6
-
Table 2-7 Invariant Value l l l l l l l l l l l l l l l 52
-
Table 2-7a MaximumValues l l l l l l l l l l l l l l l 52
-
Table 2-8 Symbolic Constants for the access0 Function l l l l l 53
-
Table 2-S Symbolic Constants for the Zseek() Function l l l l l 53
-
Table 2-10 Compile-Time Symbolic Constants l l l l l l l l l 54
-
Table 2-11 Execution-Time Symbolic Constants l l l l l l l l 55
-
Table 3-l Required Signals l l l l l l l l l l l l l l l 71
-
Job Control Signals l l l l l l l l l l l l l l 71
Table 3-2
-
Table 3-3 Memory Protection Signals l l l l l l l l l l l
-
Table 4-l uname() Structure Members l l l l l l l l l l l 105
-
Table 4-2 Configurable System Variables l l l l l l l l l l 111
-
Table 5-l stat Structure l l l l l l l l l l l l l l l l 132
-
Table 5-2 Configurable Pathname Variables l l l l l l l l l 144
-
Table 6-l cmd Values forfcntZ() l l l l l l l l l l l l l 157
-
File Descriptor Flags Used for fcntZ() l l l l l l l l 157
Table 6-2
-
Table 6-3 Z type Values for Record Locking With fcntZ() l l l l l 157
-
l
Table 6-4 ofirag Values for open0 l l l l l l l l l 157
-
Table 6-5 File Status Flags Used for open () and fLzt~() l l l l l l 158
-
Table 6-6 File Access Modes Used for open () and fcntZ() l l l l l 158
-
Table 6-7 Mask for Use With File Access Modes l l l l l l l l 158
-
Table 6-8 flock Structure l l l l l l l l l l l l l l l l 159
fcntZ( > Return Values l l l l l l l l l l l l l 160
Table 6-S
termios Structure l l l l l l l l l l l l l l l
Table 7-l 190
Table 7-2 termios c ifZag Field l l l l l l l l l l l l l l 190
-
termios c @Zag Field l l l l l l l l l l l l l l
Table 7-3 192
-
Table 7-4 termios c ZfZag Field l l l l l l l l l l l l l l 193
-
Table 7-5 termios c CC Special Control Characters l l l l l l l 194
-
Table 7-6 termios Baud Rate Values l l l l l l l l l l l l 195
-
group Structure l l l l l l l l l l l l l l l 226
Table 9-l
-
passwd Structure l l l l l l l l l l l l l l l 228
Table 9-2
Table 10-l - tar Header Block l l l l l l l l l l l l l l 232
- Byte-Oriented cpio Archive Entry l l l l l l l l 236
Table 10-2
- Values for cpio c mode Field l l l l l l l l l l
Table 10-3 237
-
Table 12-l - Memory Protection Values l l l l l l l l l l l 273
Table B-l - Suggested Feature Test Macros l l l l l l l l l l 409
Table F-l - Portabilitv Capabilitv Summary l l l l l l l l l 618
Foreword
IS0 (the International Organization for Standardization) and IEC (the Interna-
tional Electrotechnical Commission) form the specialized system for worldwide
standardization. National bodies that are members of IS0 or IEC participate in
the development of International Standards through technical committees esta-
blished by the respective organization to deal with particular fields of technical
activity. IS0 and IEC technical committees collaborate in fields of mutual
interest. Other international organizations, governmental and nongovernmental,
in liaison with IS0 and IEC, also take part in the work.
9 In the field of information technology, IS0 and IEC have established a joint techni-
10 cal committee, ISO/IEC JTC 1. Draft International Standards adopted by the joint
11 technical committee are circulated to national bodies for voting. Publication as an
12 International Standard requires approval by at least 75% of the national bodies
13 casting a vote.
14 International Standard ISO/IEC 9945-l: 1996 was prepared by Joint Technical
15 Committee ISO/IEC JTC 1, Information technology. This edition cancels and
16 replaces the first edition (ISO/IEC 9945.1:1990), which has been technically
revised. This edition also consolidates Amendments 1 and 2 and Technical Corri-
18 gendum 1 to ISO/IEC 9945.1:1990.
19 ISO/IEC 9945 consists of the following parts, under the general title Information
20 technology-Portable operating system interface (POSIX) :
21 - Part 1: System application program interface (API) [C Language]
22 - Part 2: SheZZ and utilities
23 - Part 3: System administration (under development)
24 Annexes A to H of ISO/IEC 9945-1 are provided for information only.
Foreword xi
Introduction
(This introduction is not a normative part of ISO/IEC 9945-1, Information technology-Portable
Operating System Interface (POSIX)-Part 1: System Application Programming Interface (API)
K Language1 1
1 The purpose of this part of ISO/IEC 9945 is to define a standard operating system
2 interface and environment based on the UN&) Operating System documentation
3 to support application portability at the source level. This is intended for systems
4 implementors and applications software developers.
Initially, 2, the focus of this part of ISO/IEC 9945 is to provide standardized ser-
6 vices via a C language interface. Future revisions are expected to contain bind-
7 ings for other programming languages as well as for the C language. This will be
8 - accomplished by breaking this part of ISO/IEC 9945 into multiple portions-one
9 defining core requirements independent of any programming language, and oth-
10 ers composed of programming language bindings.
11 The core requirements portion will define a set of required services common to
12 any programming language that can be reasonably expected to form a language
13 binding to this part of ISO/IEC 9945. These services will be described in terms of
14 functional requirements and will not define programming language-dependent
15 interfaces. Language bindings will consist of two major parts. One will contain
16 the programming language’s standardized interface for accessing the core services
17 defined in the programming language-independent core requirements section of
18 this part of ISO/IEC 9945. The other will contain a standardized interface for
19 language-specific services. Any implementation claiming conformance to this part
20 of ISO/IEC 9945 with any language binding will be required to comply with both
21 sections of the language binding.
22 Within this document, the term “POSIX.1” refers to this part of ISO/IEC 9945
23 itself.
24 Organization of This Part of ISO/IEC 9945
25 This part of ISO/IEC 9945 is divided into four elements:
26 Statement of scope and list of normative references (Section 1)
(1)
27 (2) Definitions and global concepts (Section 2)
28 (3) The various interface facilities (Sections 3 through 9 and 11 through 18)
n erchange format (Section 10)
29 (4) Data i t
31 1) UNIX is a registered trademark in the USA and other countries licensed exclusively through
32 X/Open.
33 2) The vertical rules in the right margin depict technical or significant non-editorial changes from
34 ISO/IEC 99451-1990. A vertical rule beside an empty line indicates deleted text.
xii Introduction
Most of the sections describe a single service interface. The C Language binding
for the service interface is given in the subclause labeled Synopsis. The Descrip-
37 tion subclause provides a specification of the operation performed by the service
38 interface. Some examples may be provided to illustrate the interfaces described.
39 In most cases there are also Returns and Errors subclauses specifying return
values and possible error conditions.
40 References are used to direct the reader to
41 other related sections. Additional material to complement sections in this part of
42 ISO/IEC 9945 may be found in the Rationale and Notes, Annex B. This annex pro-
43 vides historical perspectives into the technical choices made by the developers of
44 this part of ISO/IEC 9945. It also provides information to emphasize consequences
45 of the interfaces described in the corresponding section of this part _ of
46 ISO/IEC 9945.
47 Informative annexes are not part of the standard and are provided for information
48 only. (There is a type of annex called “normative” that is part of a standard and
49 k imposes requirements, but there are currently no such normative annexes in this
50 part of ISO/IEC 9945.) They are provided for guidance and to help understanding.
51 In publishing this part of ISO/IEC 9945, its developers simply intend to provide a
52 yardstick against which various operating system implementations can be meas-
53 ured for conformance. It is not the intent of the developers to measure or rate any
54 products, to reward or sanction any vendors of products for conformance or lack of
55 conformance to this part of ISO/IEC 9945, or to attempt to enforce this part of
The responsibility for determining the
56 ISO/IEC 9945 by these or any other means.
57 degree of conformance or lack thereof with this part of ISO/IEC 9945 rests solely
58 with the individual who is evaluating the product claiming to be in conformance
59 with this part of ISO/IEC 9945.
Base Documents
61 The various interface facilities described herein are based on the 1984 lusrlgroup
62 Standard derived and published by the UniForum (formerly /usr/group) Stan-
63 dards Committee. The 1984 hsrlgroup Standard and this part of ISO/IEC 9945
64 are largely based on UNIX Seventh Edition, UNIX System III, UNIX System V,
65 4.2BSD, and 4.3BSD documentation,3) but wherever possible, compatibility with
66 other systems derived from the UNIX operating system, or systems compatible
67 with that system, has been maintained.
68 Background
69 The developers of POSIX.1 represent a cross-section of hardware manufacturers,
70 vendors of operating systems and other software development tools, software
71 designers, consultants, academics, authors, applications programmers, and oth-
72 ers. In the course of their deliberations, the developers reviewed related Ameri-
73 can and international standards, both published and in progress.
Conceptually, POSIX.1 describes a set of fundamental services needed for the
75 efficient construction of application programs. Access to these services has been
3) The standard developers are grateful to both AT&T and UniForum for permission to use their
materials.
. . .
Background x111
provided by defining an interface, using the C programming language, that estab-
80 lishes standard semantics and syntax. Since this interface enables application
81 writers to write portable applications -it was developed with that goal in mind-
an acronym for Portable Operating System
82 it has been designated POSIX,4)
83 Interface.
84 Although originated to refer to IEEE Std 1003.1-1988, the name POSIX more
85 correctly refers to a family of related standards: IEEE 1003.n and the parts of
86 International Standard ISO/IEC 9945. In earlier editions of the IEEE standard,
87 the term POSIX was used as a synonym for IEEE Std 1003.1-1988. A preferred
88 term, POSIX.1, emerged. This maintained the advantages of readability of the
89 symbol “POSIX” without being ambiguous with the POSIX family of standards.
Audience
91 The intended audience for ISO/IEC 9945 is all persons concerned with an
92 industry-wide standard operating system based on the UNIX system. This
includes at least four groups of people:
94 Persons buying hardware and software systems;
(1)
95 (2) Persons managing companies that are deciding on future corporate com-
96 puting directions;
97 Persons implementing operating systems, and especially
(3)
98 (4) Persons developing applications where portability is an objective.
99 Purpose
100 Several principles guided the development of this part of ISO/IEC 9945:
101 Application Oriented
102 The basic goal was to promote portability of application programs across
103 UNIX system environments by developing a clear, consistent, and unam-
104 biguous standard for the interface specification of a portable operating
105 system based on the UNIX system documentation.
This part of
106 ISO/IEC 9945 codifies the common, existing definition of the UNIX sys-
107 tem. There was no attempt to define a new system interface.
108 Interface, Not Implementation
109 This part of ISO/IEC 9945 defines an interface, not an implementation.
110 No distinction is made between library functions and system calls: both
111 are referred to as functions. No details of the implementation of any
112 function are given (although historical practice is sometimes indicated
113 in Annex B). Symbolic names are given for constants (such as signals
114 and error numbers) rather than numbers.
116 4) The name POSIX was suggested by Richard Stallman. It is expected to be pronounced pahz-icks,
117 as in positive, not poh-six, or other variations. The pronunciation has been published in an
attempt to promulgate a standardized way of referring to a standard operating system interface.
xiv Introduction
119 Source, Not Object, Portability
120 This part of ISO/IEC 9945 has been written so that a program written
121 and translated for execution on one conforming implementation may
122 also be translated for execution on another conforming implementation.
123 This part of ISO/IEC 9945 does not guarantee that executable (object or
124 binary) code will execute under a different conforming implementation
125 than that for which it was translated, even if the underlying hardware
126 is identical. However, few impediments were placed in the way of
127 binary compatibility, and some remarks on this are found in Annex B.
128 See B.1.3.1.1 and B.4.8.
129 The C Language
130 This part of ISO/IEC 9945 is written in terms of the standard C language
131 as specified in the C Standard {2}.5) See B.1.3 and B.l.l.l.
132 No Super-User, No System Administration
133 There was no intention to specify all aspects of an operating system.
134 System administration facilities and functions are excluded from
135 POSIX.1, and functions usable only by the super-user have not been
included. Annex B notes several such instances. Still, an implementa-
137 tion of the standard interface may also implement features not in this
138 part of ISO/IEC 9945; see 1.3.1.1. This part of ISOIIEC 9945 is also not
139 concerned with hardware constraints or system maintenance.
140 Minimal Interface, Minimally Defined
141 In keeping with the historical design principles of the UNIX system,
142 POSIX.1 is as minimal as possible. For example, it usually specifies only
one set of functions to implement a capability. Exceptions were made in
144 some cases where long tradition and many existing applications
145 included certain functions, such as creat(). In such cases, as throughout
146 POSIX.1, redundant definitions were avoided: creat() is defined as a spe-
147 cial case of open 0. Redundant functions or implementations with less
148 tradition were excluded.
149 Broadly Implementable
150 The developers of POSIX.l endeavored to make all specified functions
151 implementable across a wide range of existing and potential systems,
152 including:
153 (1) All of the current major systems that are ultimately derived from
154 the original UNIX system code (Version 7 or later)
155 (2) Compatible systems that are not derived from the original UNIX
156 system c
...








Questions, Comments and Discussion
Ask us and Technical Secretary will try to provide an answer. You can facilitate discussion about the standard in here.
Loading comments...