]> git.ipfire.org Git - thirdparty/glibc.git/blob - manual/libc.texinfo
Update.
[thirdparty/glibc.git] / manual / libc.texinfo
1 \input texinfo @c -*- Texinfo -*-
2 @comment %**start of header (This is for running Texinfo on a region.)
3 @setfilename libc.info
4 @settitle The GNU C Library
5 @setchapternewpage odd
6
7 @comment Tell install-info what to do.
8 @dircategory GNU libraries
9 @direntry
10 * Libc: (libc). C library.
11 @end direntry
12
13 @c This tells texinfo.tex to use the real section titles in xrefs in
14 @c place of the node name, when no section title is explicitly given.
15 @set xref-automatic-section-title
16 @c @smallbook
17 @comment %**end of header (This is for running Texinfo on a region.)
18
19 @c sold 0.06/1.09, print run out 21may96
20 @set EDITION 0.07 DRAFT
21 @set VERSION 2.00 Beta
22 @set UPDATED 03 Apr 1998
23 @set ISBN 1-882114-53-1
24
25 @ifinfo
26 This file documents the GNU C library.
27
28 This is Edition @value{EDITION}, last updated @value{UPDATED},
29 of @cite{The GNU C Library Reference Manual}, for Version @value{VERSION}.
30
31 Copyright (C) 1993, '94, '95, '96, '97, '98 Free Software Foundation, Inc.
32
33 Permission is granted to make and distribute verbatim copies of
34 this manual provided the copyright notice and this permission notice
35 are preserved on all copies.
36
37 @ignore
38 Permission is granted to process this file through TeX and print the
39 results, provided the printed document carries copying permission
40 notice identical to this one except for the removal of this paragraph
41 (this paragraph not being relevant to the printed manual).
42
43 @end ignore
44 Permission is granted to copy and distribute modified versions of this
45 manual under the conditions for verbatim copying, provided also that the
46 section entitled ``GNU Library General Public License'' is included
47 exactly as in the original, and provided that the entire resulting
48 derived work is distributed under the terms of a permission notice
49 identical to this one.
50
51 Permission is granted to copy and distribute translations of this manual
52 into another language, under the above conditions for modified versions,
53 except that the text of the translation of the section entitled ``GNU
54 Library General Public License'' must be approved for accuracy by the
55 Foundation.
56 @end ifinfo
57
58 @iftex
59 @shorttitlepage The GNU C Library Reference Manual
60 @end iftex
61 @titlepage
62 @center @titlefont{The GNU C Library}
63 @sp 1
64 @center @titlefont{Reference Manual}
65 @sp 2
66 @center Sandra Loosemore
67 @center with
68 @center Richard M. Stallman, Roland McGrath, Andrew Oram, and Ulrich Drepper
69 @sp 3
70 @center Edition @value{EDITION}
71 @sp 1
72 @center last updated @value{UPDATED}
73 @sp 1
74 @center for version @value{VERSION}
75 @page
76 @vskip 0pt plus 1filll
77 Copyright @copyright{} 1993, '94, '95, '96, '97, '98 Free Software Foundation, Inc.
78 @sp 2
79 Published by the Free Software Foundation @*
80 59 Temple Place -- Suite 330, @*
81 Boston, MA 02111-1307 USA @*
82 Printed copies are available for $50 each. @*
83 ISBN @value{ISBN} @*
84
85 Permission is granted to make and distribute verbatim copies of
86 this manual provided the copyright notice and this permission notice
87 are preserved on all copies.
88
89 Permission is granted to copy and distribute modified versions of this
90 manual under the conditions for verbatim copying, provided also that the
91 section entitled ``GNU Library General Public License'' is included
92 exactly as in the original, and provided that the entire resulting
93 derived work is distributed under the terms of a permission notice
94 identical to this one.
95
96 Permission is granted to copy and distribute translations of this manual
97 into another language, under the above conditions for modified versions,
98 except that the text of the translation of the section entitled ``GNU
99 Library General Public License'' must be approved for accuracy by the
100 Foundation.
101 @end titlepage
102 @page
103
104 @ifinfo
105 @node Top, Introduction, (dir), (dir)
106 @top Main Menu
107 This is Edition @value{EDITION}, last updated @value{UPDATED}, of
108 @cite{The GNU C Library Reference Manual}, for Version @value{VERSION}
109 of the GNU C Library.
110 @end ifinfo
111
112
113 @menu
114 * Introduction:: Purpose of the GNU C Library.
115 * Error Reporting:: How the GNU Library functions report
116 error conditions.
117 * Memory Allocation:: Your program can allocate memory dynamically
118 and manipulate it via pointers.
119 * Character Handling:: Character testing and conversion functions.
120 * String and Array Utilities:: Utilities for copying and comparing
121 strings and arrays.
122 * Extended Characters:: Support for extended character sets.
123 * Locales:: The country and language can affect
124 the behavior of library functions.
125 * Message Translation:: How to make the program speak the users
126 language.
127 * Searching and Sorting:: General searching and sorting functions.
128 * Pattern Matching:: Matching wildcards and regular expressions,
129 and shell-style ``word expansion''.
130 * I/O Overview:: Introduction to the I/O facilities.
131 * Streams: I/O on Streams. High-level, portable I/O facilities.
132 * Low-Level I/O:: Low-level, less portable I/O.
133 * File System Interface:: Functions for manipulating files.
134 * Pipes and FIFOs:: A simple interprocess communication mechanism.
135 * Sockets:: A more complicated interprocess communication
136 mechanism, with support for networking.
137 * Low-Level Terminal Interface::How to change the characteristics
138 of a terminal device.
139 * Mathematics:: Math functions (transcendental functions,
140 random numbers, absolute value, etc.).
141 * Arithmetic:: Low-level arithmetic functions.
142 * Date and Time:: Functions for getting the date and time,
143 and for conversion between formats.
144 * Non-Local Exits:: The @code{setjmp} and @code{longjmp} facilities.
145 * Signal Handling:: All about signals; how to send them,
146 block them, and handle them.
147 * Process Startup:: Writing the beginning and end of your program.
148 * Processes:: How to create processes and run other programs.
149 * Job Control:: All about process groups and sessions.
150 * Name Service Switch:: Accessing the various system databases.
151 * Users and Groups:: How users are identified and classified.
152 * System Information:: Getting information about the
153 hardware and software configuration
154 of the machine a program runs on.
155 * System Configuration:: Parameters describing operating system limits.
156
157 Appendices
158
159 * Language Features:: C language features provided by the library.
160
161 * Library Summary:: A summary showing the syntax, header file,
162 and derivation of each library feature.
163 * Installation:: How to install the GNU C library.
164 * Maintenance:: How to enhance and port the GNU C Library.
165 * Contributors:: Who wrote what parts of the GNU C Library.
166 * Copying:: The GNU Library General Public License says
167 how you can copy and share the GNU C Library.
168
169 Indices
170
171 * Concept Index:: Index of concepts and names.
172 * Type Index:: Index of types and type qualifiers.
173 * Function Index:: Index of functions and function-like macros.
174 * Variable Index:: Index of variables and variable-like macros.
175 * File Index:: Index of programs and files.
176
177 --- The Detailed Node Listing ---
178
179 Introduction
180
181 * Getting Started:: Getting Started
182 * Standards and Portability:: Standards and Portability
183 * Using the Library:: Using the Library
184 * Roadmap to the Manual:: Roadmap to the Manual
185
186 Standards and Portability
187
188 * ISO C:: The American National Standard for the
189 C programming language.
190 * POSIX:: The ISO/IEC 9945 (aka IEEE 1003) standards
191 for operating systems.
192 * Berkeley Unix:: BSD and SunOS.
193 * SVID:: The System V Interface Description.
194
195 Using the Library
196
197 * Header Files:: How to use the header files in your programs.
198 * Macro Definitions:: Some functions in the library may really
199 be implemented as macros.
200 * Reserved Names:: The C standard reserves some names for
201 the library, and some for users.
202 * Feature Test Macros:: How to control what names are defined.
203
204 Error Reporting
205
206 * Checking for Errors:: How errors are reported by library functions.
207 * Error Codes:: What all the error codes are.
208 * Error Messages:: Mapping error codes onto error messages.
209
210 Memory Allocation
211
212 * Memory Concepts:: An introduction to concepts and terminology.
213 * Dynamic Allocation and C:: How to get different kinds of allocation in C.
214 * Unconstrained Allocation:: The @code{malloc} facility allows fully general
215 dynamic allocation.
216 * Obstacks:: Obstacks are less general than malloc
217 but more efficient and convenient.
218 * Variable Size Automatic:: Allocation of variable-sized blocks
219 of automatic storage that are freed when the
220 calling function returns.
221 * Relocating Allocator:: Waste less memory, if you can tolerate
222 automatic relocation of the blocks you get.
223
224 Unconstrained Allocation
225
226 * Basic Allocation:: Simple use of @code{malloc}.
227 * Malloc Examples:: Examples of @code{malloc}. @code{xmalloc}.
228 * Freeing after Malloc:: Use @code{free} to free a block you
229 got with @code{malloc}.
230 * Changing Block Size:: Use @code{realloc} to make a block
231 bigger or smaller.
232 * Allocating Cleared Space:: Use @code{calloc} to allocate a
233 block and clear it.
234 * Efficiency and Malloc:: Efficiency considerations in use of
235 these functions.
236 * Aligned Memory Blocks:: Allocating specially aligned memory:
237 @code{memalign} and @code{valloc}.
238 * Heap Consistency Checking:: Automatic checking for errors.
239 * Hooks for Malloc:: You can use these hooks for debugging
240 programs that use @code{malloc}.
241 * Statistics of Malloc:: Getting information about how much
242 memory your program is using.
243 * Summary of Malloc:: Summary of @code{malloc} and related functions.
244
245 Obstacks
246
247 * Creating Obstacks:: How to declare an obstack in your program.
248 * Preparing for Obstacks:: Preparations needed before you can
249 use obstacks.
250 * Allocation in an Obstack:: Allocating objects in an obstack.
251 * Freeing Obstack Objects:: Freeing objects in an obstack.
252 * Obstack Functions:: The obstack functions are both
253 functions and macros.
254 * Growing Objects:: Making an object bigger by stages.
255 * Extra Fast Growing:: Extra-high-efficiency (though more
256 complicated) growing objects.
257 * Status of an Obstack:: Inquiries about the status of an obstack.
258 * Obstacks Data Alignment:: Controlling alignment of objects in obstacks.
259 * Obstack Chunks:: How obstacks obtain and release chunks.
260 Efficiency considerations.
261 * Summary of Obstacks::
262
263 Automatic Storage with Variable Size
264
265 * Alloca Example:: Example of using @code{alloca}.
266 * Advantages of Alloca:: Reasons to use @code{alloca}.
267 * Disadvantages of Alloca:: Reasons to avoid @code{alloca}.
268 * GNU C Variable-Size Arrays:: Only in GNU C, here is an alternative
269 method of allocating dynamically and
270 freeing automatically.
271 Relocating Allocator
272
273 * Relocator Concepts:: How to understand relocating allocation.
274 * Using Relocator:: Functions for relocating allocation.
275
276 Character Handling
277
278 * Classification of Characters::Testing whether characters are
279 letters, digits, punctuation, etc.
280 * Case Conversion:: Case mapping, and the like.
281
282 String and Array Utilities
283
284 * Representation of Strings:: Introduction to basic concepts.
285 * String/Array Conventions:: Whether to use a string function or an
286 arbitrary array function.
287 * String Length:: Determining the length of a string.
288 * Copying and Concatenation:: Functions to copy the contents of strings
289 and arrays.
290 * String/Array Comparison:: Functions for byte-wise and character-wise
291 comparison.
292 * Collation Functions:: Functions for collating strings.
293 * Search Functions:: Searching for a specific element or substring.
294 * Finding Tokens in a String:: Splitting a string into tokens by looking
295 for delimiters.
296
297 Extended Characters
298
299 * Extended Char Intro:: Multibyte codes versus wide characters.
300 * Locales and Extended Chars:: The locale selects the character codes.
301 * Multibyte Char Intro:: How multibyte codes are represented.
302 * Wide Char Intro:: How wide characters are represented.
303 * Wide String Conversion:: Converting wide strings to multibyte code
304 and vice versa.
305 * Length of Char:: how many bytes make up one multibyte char.
306 * Converting One Char:: Converting a string character by character.
307 * Example of Conversion:: Example showing why converting
308 one character at a time may be useful.
309 * Shift State:: Multibyte codes with "shift characters".
310
311 Locales and Internationalization
312
313 * Effects of Locale:: Actions affected by the choice of locale.
314 * Choosing Locale:: How the user specifies a locale.
315 * Locale Categories:: Different purposes for which
316 you can select a locale.
317 * Setting the Locale:: How a program specifies the locale.
318 * Standard Locales:: Locale names available on all systems.
319 * Numeric Formatting:: How to format numbers for the chosen locale.
320
321 Message Translation
322
323 * Message catalogs a la X/Open:: The @code{catgets} family of functions.
324 * The Uniforum approach:: The @code{gettext} family of functions.
325
326 Searching and Sorting
327
328 * Comparison Functions:: Defining how to compare two objects.
329 Since the sort and search facilities are
330 general, you have to specify the ordering.
331 * Array Search Function:: The @code{bsearch} function.
332 * Array Sort Function:: The @code{qsort} function.
333 * Search/Sort Example:: An example program.
334
335 Pattern Matching
336
337 * Wildcard Matching:: Matching a wildcard pattern against a single string.
338 * Globbing:: Finding the files that match a wildcard pattern.
339 * Regular Expressions:: Matching regular expressions against strings.
340 * Word Expansion:: Expanding shell variables, nested commands,
341 arithmetic, and wildcards.
342 This is what the shell does with shell commands.
343
344 I/O Overview
345
346 * I/O Concepts:: Some basic information and terminology.
347 * File Names:: How to refer to a file.
348
349 I/O Concepts
350
351 * Streams and File Descriptors:: The GNU Library provides two ways
352 to access the contents of files.
353 * File Position:: The number of bytes from the
354 beginning of the file.
355
356 File Names
357
358 * Directories:: Directories contain entries for files.
359 * File Name Resolution:: A file name specifies how to look up a file.
360 * File Name Errors:: Error conditions relating to file names.
361 * File Name Portability:: File name portability and syntax issues.
362
363 I/O on Streams
364
365 * Streams:: About the data type representing a stream.
366 * Standard Streams:: Streams to the standard input and output
367 devices are created for you.
368 * Opening Streams:: How to create a stream to talk to a file.
369 * Closing Streams:: Close a stream when you are finished with it.
370 * Simple Output:: Unformatted output by characters and lines.
371 * Character Input:: Unformatted input by characters and words.
372 * Line Input:: Reading a line or a record from a stream.
373 * Unreading:: Peeking ahead/pushing back input just read.
374 * Formatted Output:: @code{printf} and related functions.
375 * Customizing Printf:: You can define new conversion specifiers for
376 @code{printf} and friends.
377 * Formatted Input:: @code{scanf} and related functions.
378 * Block Input/Output:: Input and output operations on blocks of data.
379 * EOF and Errors:: How you can tell if an I/O error happens.
380 * Binary Streams:: Some systems distinguish between text files
381 and binary files.
382 * File Positioning:: About random-access streams.
383 * Portable Positioning:: Random access on peculiar ISO C systems.
384 * Stream Buffering:: How to control buffering of streams.
385 * Temporary Files:: How to open a temporary file.
386 * Other Kinds of Streams:: Other Kinds of Streams
387
388 Unreading
389
390 * Unreading Idea:: An explanation of unreading with pictures.
391 * How Unread:: How to call @code{ungetc} to do unreading.
392
393 Formatted Output
394
395 * Formatted Output Basics:: Some examples to get you started.
396 * Output Conversion Syntax:: General syntax of conversion specifications.
397 * Table of Output Conversions:: Summary of output conversions, what they do.
398 * Integer Conversions:: Details of formatting integers.
399 * Floating-Point Conversions:: Details of formatting floating-point numbers.
400 * Other Output Conversions:: Details about formatting of strings,
401 characters, pointers, and the like.
402 * Formatted Output Functions:: Descriptions of the actual functions.
403 * Variable Arguments Output:: @code{vprintf} and friends.
404 * Parsing a Template String:: What kinds of arguments does
405 a given template call for?
406
407 Customizing Printf
408
409 * Registering New Conversions::
410 * Conversion Specifier Options::
411 * Defining the Output Handler::
412 * Printf Extension Example::
413
414 Formatted Input
415
416 * Formatted Input Basics:: Some basics to get you started.
417 * Input Conversion Syntax:: Syntax of conversion specifications.
418 * Table of Input Conversions:: Summary of input conversions and what they do.
419 * Numeric Input Conversions:: Details of conversions for reading numbers.
420 * String Input Conversions:: Details of conversions for reading strings.
421 * Other Input Conversions:: Details of miscellaneous other conversions.
422 * Formatted Input Functions:: Descriptions of the actual functions.
423 * Variable Arguments Input:: @code{vscanf} and friends.
424
425 Stream Buffering
426
427 * Buffering Concepts:: Terminology is defined here.
428 * Flushing Buffers:: How to ensure that output buffers are flushed.
429 * Controlling Buffering:: How to specify what kind of buffering to use.
430
431 Other Kinds of Streams
432
433 * String Streams::
434 * Custom Streams::
435
436 Programming Your Own Custom Streams
437
438 * Streams and Cookies::
439 * Hook Functions::
440
441 Low-Level I/O
442
443 * Opening and Closing Files:: How to open and close file descriptors.
444 * I/O Primitives:: Reading and writing data.
445 * File Position Primitive:: Setting a descriptor's file position.
446 * Descriptors and Streams:: Converting descriptor to stream or vice-versa.
447 * Stream/Descriptor Precautions:: Precautions needed if you use both
448 descriptors and streams.
449 * Waiting for I/O:: How to check for input or output
450 on multiple file descriptors.
451 * Control Operations:: Various other operations on file descriptors.
452 * Duplicating Descriptors:: Fcntl commands for duplicating descriptors.
453 * Descriptor Flags:: Fcntl commands for manipulating flags
454 associated with file descriptors.
455 * File Status Flags:: Fcntl commands for manipulating flags
456 associated with open files.
457 * File Locks:: Fcntl commands for implementing file locking.
458 * Interrupt Input:: Getting a signal when input arrives.
459
460 File System Interface
461
462 * Working Directory:: This is used to resolve relative file names.
463 * Accessing Directories:: Finding out what files a directory contains.
464 * Hard Links:: Adding alternate names to a file.
465 * Symbolic Links:: A file that ``points to'' a file name.
466 * Deleting Files:: How to delete a file, and what that means.
467 * Renaming Files:: Changing a file's name.
468 * Creating Directories:: A system call just for creating a directory.
469 * File Attributes:: Attributes of individual files.
470 * Making Special Files:: How to create special files.
471
472 Accessing Directories
473
474 * Directory Entries:: Format of one directory entry.
475 * Opening a Directory:: How to open a directory stream.
476 * Reading/Closing Directory:: How to read directory entries from the stream.
477 * Simple Directory Lister:: A very simple directory listing program.
478 * Random Access Directory:: Rereading part of the directory
479 already read with the same stream.
480
481 File Attributes
482
483 * Attribute Meanings:: The names of the file attributes,
484 and what their values mean.
485 * Reading Attributes:: How to read the attributes of a file.
486 * Testing File Type:: Distinguishing ordinary files,
487 directories, links...
488 * File Owner:: How ownership for new files is determined,
489 and how to change it.
490 * Permission Bits:: How information about a file's access mode
491 is stored.
492 * Access Permission:: How the system decides who can access a file.
493 * Setting Permissions:: How permissions for new files are assigned,
494 and how to change them.
495 * Testing File Access:: How to find out if your process can
496 access a file.
497 * File Times:: About the time attributes of a file.
498
499 Pipes and FIFOs
500
501 * Creating a Pipe:: Making a pipe with the @code{pipe} function.
502 * Pipe to a Subprocess:: Using a pipe to communicate with a child.
503 * FIFO Special Files:: Making a FIFO special file.
504
505 Sockets
506
507 * Socket Concepts:: Basic concepts you need to know about.
508 * Communication Styles:: Stream communication, datagrams, and others.
509 * Socket Addresses:: How socket names (``addresses'') work.
510 * Local Namespace:: Details about the local namespace.
511 * Internet Namespace:: Details about the Internet namespace.
512 * Open/Close Sockets:: Creating sockets and destroying them.
513 * Connections:: Operations on sockets with connection state.
514 * Datagrams:: Operations on datagram sockets.
515 * Socket Options:: Miscellaneous low-level socket options.
516 * Networks Database:: Accessing the database of network names.
517
518 Socket Addresses
519
520 * Address Formats:: About @code{struct sockaddr}.
521 * Setting Address:: Binding an address to a socket.
522 * Reading Address:: Reading the address of a socket.
523
524 Internet Domain
525
526 * Internet Address Formats:: How socket addresses are specified in the
527 Internet namespace.
528 * Host Addresses:: All about host addresses of Internet hosts.
529 * Protocols Database:: Referring to protocols by name.
530 * Services Database:: Ports may have symbolic names.
531 * Byte Order:: Different hosts may use different byte
532 ordering conventions; you need to
533 canonicalize host address and port number.
534 * Inet Example:: Putting it all together.
535
536 Host Addresses
537
538 * Abstract Host Addresses:: What a host number consists of.
539 * Data type: Host Address Data Type. Data type for a host number.
540 * Functions: Host Address Functions. Functions to operate on them.
541 * Names: Host Names. Translating host names to host numbers.
542
543 Open/Close Sockets
544
545 * Creating a Socket:: How to open a socket.
546 * Closing a Socket:: How to close a socket.
547 * Socket Pairs:: These are created like pipes.
548
549 Connections
550
551 * Connecting:: What the client program must do.
552 * Listening:: How a server program waits for requests.
553 * Accepting Connections:: What the server does when it gets a request.
554 * Who is Connected:: Getting the address of the
555 other side of a connection.
556 * Transferring Data:: How to send and receive data.
557 * Byte Stream Example:: An example client for communicating over a
558 byte stream socket in the Internet namespace.
559 * Server Example:: A corresponding server program.
560 * Out-of-Band Data:: This is an advanced feature.
561
562 Transferring Data
563
564 * Sending Data:: Sending data with @code{write}.
565 * Receiving Data:: Reading data with @code{read}.
566 * Socket Data Options:: Using @code{send} and @code{recv}.
567
568 Datagrams
569
570 * Sending Datagrams:: Sending packets on a datagram socket.
571 * Receiving Datagrams:: Receiving packets on a datagram socket.
572 * Datagram Example:: An example program: packets sent over a
573 datagram stream in the local namespace.
574 * Example Receiver:: Another program, that receives those packets.
575
576 Socket Options
577
578 * Socket Option Functions:: The basic functions for setting and getting
579 socket options.
580 * Socket-Level Options:: Details of the options at the socket level.
581
582 Low-Level Terminal Interface
583
584 * Is It a Terminal:: How to determine if a file is a terminal
585 device, and what its name is.
586 * I/O Queues:: About flow control and typeahead.
587 * Canonical or Not:: Two basic styles of input processing.
588 * Terminal Modes:: How to examine and modify flags controlling
589 terminal I/O: echoing, signals, editing.
590 * Line Control:: Sending break sequences, clearing buffers...
591 * Noncanon Example:: How to read single characters without echo.
592
593 Terminal Modes
594
595 * Mode Data Types:: The data type @code{struct termios} and related types.
596 * Mode Functions:: Functions to read and set terminal attributes.
597 * Setting Modes:: The right way to set attributes reliably.
598 * Input Modes:: Flags controlling low-level input handling.
599 * Output Modes:: Flags controlling low-level output handling.
600 * Control Modes:: Flags controlling serial port behavior.
601 * Local Modes:: Flags controlling high-level input handling.
602 * Line Speed:: How to read and set the terminal line speed.
603 * Special Characters:: Characters that have special effects,
604 and how to change them.
605 * Noncanonical Input:: Controlling how long to wait for input.
606
607 Special Characters
608
609 * Editing Characters::
610 * Signal Characters::
611 * Start/Stop Characters::
612
613 Mathematics
614
615 * Domain and Range Errors:: How overflow conditions and the
616 like are reported.
617 * Not a Number:: Making NANs and testing for NANs.
618 * Trig Functions:: Sine, cosine, and tangent.
619 * Inverse Trig Functions:: Arc sine, arc cosine, and arc tangent.
620 * Exponents and Logarithms:: Also includes square root.
621 * Hyperbolic Functions:: Hyperbolic sine and friends.
622 * Pseudo-Random Numbers:: Functions for generating pseudo-random numbers.
623 * Absolute Value:: Absolute value functions.
624
625 Pseudo-Random Numbers
626
627 * ISO Random:: @code{rand} and friends.
628 * BSD Random:: @code{random} and friends.
629
630 Low-Level Arithmetic Functions
631
632 * Normalization Functions:: Hacks for radix-2 representations.
633 * Rounding and Remainders:: Determining the integer and
634 fractional parts of a float.
635 * Integer Division:: Functions for performing integer division.
636 * Parsing of Numbers:: Functions for ``reading'' numbers from strings.
637 * Predicates on Floats:: Some miscellaneous test functions.
638
639 Parsing of Numbers
640
641 * Parsing of Integers:: Functions for conversion of integer values.
642 * Parsing of Floats:: Functions for conversion of floating-point.
643
644 Date and Time
645
646 * Processor Time:: Measures processor time used by a program.
647 * Calendar Time:: Manipulation of ``real'' dates and times.
648 * Setting an Alarm:: Sending a signal after a specified time.
649 * Sleeping:: Waiting for a period of time.
650
651 Processor Time
652
653 * Basic CPU Time:: The @code{clock} function.
654 * Detailed CPU Time:: The @code{times} function.
655
656 Calendar Time
657
658 * Simple Calendar Time:: Facilities for manipulating calendar time.
659 * High-Resolution Calendar:: A time representation with greater precision.
660 * Broken-down Time:: Facilities for manipulating local time.
661 * Formatting Date and Time:: Converting times to strings.
662 * TZ Variable:: How users specify the time zone.
663 * Time Zone Functions:: Functions to examine or specify the time zone.
664 * Time Functions Example:: An example program showing use of some of
665 the time functions.
666
667 Signal Handling
668
669 * Concepts of Signals:: Introduction to the signal facilities.
670 * Standard Signals:: Particular kinds of signals with standard
671 names and meanings.
672 * Signal Actions:: Specifying what happens when a particular
673 signal is delivered.
674 * Defining Handlers:: How to write a signal handler function.
675 * Generating Signals:: How to send a signal to a process.
676 * Blocking Signals:: Making the system hold signals temporarily.
677 * Waiting for a Signal:: Suspending your program until a signal arrives.
678 * Signal Stack:: Using a Separate Signal Stack
679 * BSD Signal Handling:: Additional functions for backward
680 compatibility with BSD.
681
682 Basic Concepts of Signals
683
684 * Kinds of Signals:: Some examples of what can cause a signal.
685 * Signal Generation:: Concepts of why and how signals occur.
686 * Delivery of Signal:: Concepts of what a signal does to the process.
687
688 Standard Signals
689
690 * Program Error Signals:: Used to report serious program errors.
691 * Termination Signals:: Used to interrupt and/or terminate the program.
692 * Alarm Signals:: Used to indicate expiration of timers.
693 * Asynchronous I/O Signals:: Used to indicate input is available.
694 * Job Control Signals:: Signals used to support job control.
695 * Operation Error Signals:: Used to report operational system errors.
696 * Miscellaneous Signals:: Miscellaneous Signals.
697 * Signal Messages:: Printing a message describing a signal.
698
699 Specifying Signal Actions
700
701 * Basic Signal Handling:: The simple @code{signal} function.
702 * Advanced Signal Handling:: The more powerful @code{sigaction} function.
703 * Signal and Sigaction:: How those two functions interact.
704 * Sigaction Function Example:: An example of using the sigaction function.
705 * Flags for Sigaction:: Specifying options for signal handling.
706 * Initial Signal Actions:: How programs inherit signal actions.
707
708 Defining Signal Handlers
709
710 * Handler Returns::
711 * Termination in Handler::
712 * Longjmp in Handler::
713 * Signals in Handler::
714 * Nonreentrancy::
715 * Atomic Data Access::
716
717 Generating Signals
718
719 * Signaling Yourself:: Signaling Yourself
720 * Signaling Another Process:: Send a signal to another process.
721 * Permission for kill:: Permission for using @code{kill}
722 * Kill Example:: Using @code{kill} for Communication
723
724 Blocking Signals
725
726 * Why Block:: The purpose of blocking signals.
727 * Signal Sets:: How to specify which signals to block.
728 * Process Signal Mask:: Blocking delivery of signals to your
729 process during normal execution.
730 * Testing for Delivery:: Blocking to Test for Delivery of a Signal
731 * Blocking for Handler:: Blocking additional signals while a
732 handler is being run.
733 * Checking for Pending Signals::Checking for Pending Signals
734 * Remembering a Signal:: How you can get almost the same effect
735 as blocking a signal, by handling it
736 and setting a flag to be tested later.
737
738 Waiting for a Signal
739
740 * Using Pause:: The simple way, using @code{pause}.
741 * Pause Problems:: Why the simple way is often not very good.
742 * Sigsuspend:: Reliably waiting for a specific signal.
743
744 BSD Signal Handling
745
746 * BSD Handler:: BSD Function to Establish a Handler.
747 * Blocking in BSD:: BSD Functions for Blocking Signals
748
749 Process Startup and Termination
750
751 * Program Arguments:: Parsing your program's command-line arguments.
752 * Environment Variables:: How to access parameters inherited from
753 a parent process.
754 * Program Termination:: How to cause a process to terminate and
755 return status information to its parent.
756
757 Program Arguments
758
759 * Argument Syntax:: By convention, options start with a hyphen.
760 * Parsing Program Arguments:: Ways to parse program options and arguments.
761
762 Parsing Program Arguments
763
764 * Getopt:: Parsing program options using @code{getopt}.
765 * Argp:: Parsing program options using @code{argp_parse}.
766 * Suboptions:: Some programs need more detailed options.
767 * Suboptions Example:: This shows how it could be done for @code{mount}.
768
769 Environment Variables
770
771 * Environment Access:: How to get and set the values of
772 environment variables.
773 * Standard Environment:: These environment variables have
774 standard interpretations.
775
776 Program Termination
777
778 * Normal Termination:: If a program calls @code{exit}, a
779 process terminates normally.
780 * Exit Status:: The @code{exit status} provides information
781 about why the process terminated.
782 * Cleanups on Exit:: A process can run its own cleanup
783 functions upon normal termination.
784 * Aborting a Program:: The @code{abort} function causes
785 abnormal program termination.
786 * Termination Internals:: What happens when a process terminates.
787
788
789 Child Processes
790
791 * Running a Command:: The easy way to run another program.
792 * Process Creation Concepts:: An overview of the hard way to do it.
793 * Process Identification:: How to get the process ID of a process.
794 * Creating a Process:: How to fork a child process.
795 * Executing a File:: How to make a child execute another program.
796 * Process Completion:: How to tell when a child process has completed.
797 * Process Completion Status:: How to interpret the status value
798 returned from a child process.
799 * BSD Wait Functions:: More functions, for backward compatibility.
800 * Process Creation Example:: A complete example program.
801
802 Job Control
803
804 * Concepts of Job Control :: Concepts of Job Control
805 * Job Control is Optional:: Not all POSIX systems support job control.
806 * Controlling Terminal:: How a process gets its controlling terminal.
807 * Access to the Terminal:: How processes share the controlling terminal.
808 * Orphaned Process Groups:: Jobs left after the user logs out.
809 * Implementing a Shell:: What a shell must do to implement job control.
810 * Functions for Job Control:: Functions to control process groups.
811
812 Implementing a Job Control Shell
813
814 * Data Structures:: Introduction to the sample shell.
815 * Initializing the Shell:: What the shell must do to take
816 responsibility for job control.
817 * Launching Jobs:: Creating jobs to execute commands.
818 * Foreground and Background:: Putting a job in foreground of background.
819 * Stopped and Terminated Jobs:: Reporting job status.
820 * Continuing Stopped Jobs:: How to continue a stopped job in
821 the foreground or background.
822 * Missing Pieces:: Other parts of the shell.
823
824 Functions for Job Control
825
826 * Identifying the Terminal:: Determining the controlling terminal's name.
827 * Process Group Functions:: Functions for manipulating process groups.
828 * Terminal Access Functions:: Functions for controlling terminal access.
829
830 Name Service Switch
831
832 * NSS Basics:: What is this NSS good for.
833 * NSS Configuration File:: Configuring NSS.
834 * NSS Module Internals:: How does it work internally.
835 * Extending NSS:: What to do to add services or databases.
836
837 Users and Groups
838
839 * User and Group IDs:: Each user and group has a unique numeric ID.
840 * Process Persona:: The user IDs and group IDs of a process.
841 * Why Change Persona:: Why a program might need to change
842 its user and/or group IDs.
843 * How Change Persona:: Restrictions on changing user and group IDs.
844 * Reading Persona:: Examining the process's user and group IDs.
845 * Setting User ID::
846 * Setting Groups::
847 * Enable/Disable Setuid::
848 * Setuid Program Example:: Setuid Program Example
849 * Tips for Setuid::
850 * Who Logged In:: Getting the name of the user who logged in,
851 or of the real user ID of the current process.
852
853 * User Database:: Functions and data structures for
854 accessing the user database.
855 * Group Database:: Functions and data structures for
856 accessing the group database.
857 * Database Example:: Example program showing use of database
858 inquiry functions.
859
860 User Database
861
862 * User Data Structure::
863 * Lookup User::
864 * Scanning All Users:: Scanning the List of All Users
865 * Writing a User Entry::
866
867 Group Database
868
869 * Group Data Structure::
870 * Lookup Group::
871 * Scanning All Groups:: Scanning the List of All Groups
872
873 System Information
874
875 * Host Identification:: Determining the name of the machine.
876 * Hardware/Software Type ID:: Determining the hardware type and
877 operating system type.
878
879 System Configuration Limits
880
881 * General Limits:: Constants and functions that describe
882 various process-related limits that have
883 one uniform value for any given machine.
884 * System Options:: Optional POSIX features.
885 * Version Supported:: Version numbers of POSIX.1 and POSIX.2.
886 * Sysconf:: Getting specific configuration values
887 of general limits and system options.
888 * Minimums:: Minimum values for general limits.
889
890 * Limits for Files:: Size limitations on individual files.
891 These can vary between file systems
892 or even from file to file.
893 * Options for Files:: Optional features that some files may support.
894 * File Minimums:: Minimum values for file limits.
895 * Pathconf:: Getting the limit values for a particular file.
896
897 * Utility Limits:: Capacity limits of POSIX.2 utility programs.
898 * Utility Minimums:: Minimum allowable values of those limits.
899
900 * String Parameters:: Getting the default search path.
901
902 Library Facilities that are Part of the C Language
903
904 * Consistency Checking:: Using @code{assert} to abort
905 if something ``impossible'' happens.
906 * Variadic Functions:: Defining functions with varying
907 numbers of arguments.
908 * Null Pointer Constant:: The macro @code{NULL}.
909 * Important Data Types:: Data types for object sizes.
910 * Data Type Measurements:: Parameters of data type representations.
911
912 Variadic Functions
913
914 * Why Variadic:: Reasons for making functions take
915 variable arguments.
916 * How Variadic:: How to define and call variadic functions.
917 * Argument Macros:: Detailed specification of the macros
918 for accessing variable arguments.
919 * Variadic Example:: A complete example.
920
921 How Variadic Functions are Defined and Used
922
923 * Variadic Prototypes:: How to make a prototype for a function
924 with variable arguments.
925 * Receiving Arguments:: Steps you must follow to access the
926 optional argument values.
927 * How Many Arguments:: How to decide whether there are more arguments.
928 * Calling Variadics:: Things you need to know about calling
929 variable arguments functions.
930
931 Data Type Measurements
932
933 * Width of Type:: How many bits does an integer type hold?
934 * Range of Type:: What are the largest and smallest values
935 that an integer type can hold?
936 * Floating Type Macros:: Parameters that measure floating-point types.
937 * Structure Measurement:: Getting measurements on structure types.
938
939 Floating Type Macros
940
941 * Floating Point Concepts:: Definitions of terminology.
942 * Floating Point Parameters:: Dimensions, limits of floating point types.
943 * IEEE Floating Point:: How one common representation is described.
944
945 Library Maintenance
946
947 * Installation:: How to configure, compile and install
948 the GNU C library.
949 * Reporting Bugs:: How to report bugs (if you want to
950 get them fixed) and other troubles
951 you may have with the GNU C library.
952 @c * Traditional C Compatibility:: Using the GNU C library with non-ANSI
953 @c C compilers.
954
955 Porting the GNU C Library
956
957 * Hierarchy Conventions:: How the @file{sysdeps} hierarchy is
958 layed out.
959 * Porting to Unix:: Porting the library to an average
960 Unix-like system.
961 @end menu
962
963
964 @comment Includes of all the individual chapters.
965 @include intro.texi
966 @include errno.texi
967 @include memory.texi
968 @include ctype.texi
969 @include string.texi
970 @include mbyte.texi
971 @include locale.texi
972 @include message.texi
973 @include search.texi
974 @include pattern.texi
975 @include io.texi
976 @include stdio.texi
977 @include llio.texi
978 @include filesys.texi
979 @include pipe.texi
980 @include socket.texi
981 @include terminal.texi
982 @include math.texi
983 @include arith.texi
984 @include time.texi
985 @include setjmp.texi
986 @include signal.texi
987 @include startup.texi
988 @include process.texi
989 @include job.texi
990 @include nss.texi
991 @include users.texi
992 @include sysinfo.texi
993 @include conf.texi
994
995 @comment Includes of the appendices.
996 @include lang.texi
997 @include header.texi
998 @include install.texi
999 @include maint.texi
1000 @include contrib.texi
1001
1002
1003 @set lgpl-appendix
1004 @node Copying, Concept Index, Contributors, Top
1005 @include lgpl.texinfo
1006
1007
1008 @node Concept Index, Type Index, Copying, Top
1009 @unnumbered Concept Index
1010
1011 @printindex cp
1012
1013 @node Type Index, Function Index, Concept Index, Top
1014 @unnumbered Type Index
1015
1016 @printindex tp
1017
1018 @node Function Index, Variable Index, Type Index, Top
1019 @unnumbered Function and Macro Index
1020
1021 @printindex fn
1022
1023 @node Variable Index, File Index, Function Index, Top
1024 @unnumbered Variable and Constant Macro Index
1025
1026 @printindex vr
1027
1028 @node File Index, , Variable Index, Top
1029 @unnumbered Program and File Index
1030
1031 @printindex pg
1032
1033
1034 @shortcontents
1035 @contents
1036 @bye