DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
ANSI implementation-defined behavior

Library functions

This section describes the implementation-defined characteristics of the compiler library functions. It corresponds to section ``F.3.14 Library Functions'' in the ANSI document.

Expanding the NULL macro

The macro NULL expands to the null pointer constant:

   0

Diagnostic printed by the assert function

The assert function prints the diagnostic

   "Assertion failed: <expression>, <filename>, <line number>"
On termination, the assert function prints out a string of the form:
   Assertion failed: <comparison operation>, file <source filename>, line <source line number>.

Character testing

The sets of characters that the isalnum, isalpha, iscntrl, islower, isprint, and isupper functions test for are listed below in the section ``Locale-Specific Behavior''.

Math functions and domain errors

Domain errors occur when an input argument is outside the domain over which the mathematical function is defined. When inputs are NaNs or infinities, all the mathematical functions may return various forms of NaNs. When inputs are not NaNs or infinities the values returned by the mathematics functions on the occurrence of domain errors are as presented in the following table:

Math functions and domain errors

Function Returns
pow() -HUGE_VAL or -HUGE or 0.0 depending on input values.
sqrt() 0.0
asin() 0.0
acos() 0.0
fmod() 0.0
atan2() 0.0

The value of EDOM is ``33''.

Underflow of floating-point values

On underflow range errors, the mathematics functions listed below set the integer expression errno to the value of the macro ERANGE:

The mathematics functions listed below will get range errors and set the integer expression errno to the value of the macro ERANGE only if the input argument is (±)INFINITY.

Domain errors and the fmod function

The fmod function computes the floating point remainder of x/y. A domain error occurs and zero is returned when the fmod function has a second argument of zero (errno=EDOM).

The signal function

The set of signals for the signal function are:

signal function messages

Signal Number Function
SIGHUP 1 hangup
SIGINT 2 interrupt (rubout)
SIGQUIT 3 quit (ASCII FS)
SIGILL 4 illegal instruction (not reset when caught)
SIGTRAP 5 trace trap (not reset when caught)
SIGIOT 6 IOT instruction
SIGABRT 6 used by abort, replace SIGIOT in the future
SIGEMT 7 EMT instruction
SIGFPE 8 floating point exception
SIGKILL 9 kill (cannot be caught or ignored)
SIGBUS 10 bus error
SIGSEGV 11 segmentation violation
SIGSYS 12 bad argument to system call
SIGPIPE 13 write on a pipe with no one to read it
SIGALRM 14 alarm clock
SIGTERM 15 software termination signal from kill
SIGUSR1 16 user defined signal 1
SIGUSR2 17 user defined signal 2
SIGCLD 18 death of a child
SIGCHLD 18 death of a child
SIGPWR 19 power-fail restart
SIGWINCH 20 window change
SIGPOLL 22 pollable event occurred
SIGSTOP 23 sendable stop signal not from tty
SIGTSTP 24 stop signal from tty
SIGCONT 25 continue a stopped process
SIGTTIN 26 to readers pgrp upon background tty read
SIGTTOU 27 like TTIN for output if tp->t_local&TOSTOP
SIGVTALRM 28 virtual timer alarm
SIGPROF 29 profile alarm
SIGXCPU 30 CPU time limit exceeded
SIGXFSZ 31 File size limit exceeded

Default signals

The default handling for each signal recognized by the signal function is to not ignore these signals.

A program runs in a process which inherits its handling of signals from its parent process (such as the shell). If signals are set to SIG_IGN in the parent process, that remains the same. If the signals were set to be caught in the parent they are reset to SIG_DFL which may be to ignore the signal or terminate the program. The setting of SIG_DFL remains the same.

Signal blocking

If the equivalent of "signal(sig, SIG_DFL);" is not executed prior to the call of a signal handler, signal blocking is performed. Signals are set to their default values just before program execution.

The SIGILL signal

The default is not reset if the SIGILL signal is received by a handler specified to the signal function.

Terminating new-line characters

A text stream is an ordered sequence of characters composed into lines, each line consisting of zero of more characters plus a new-line character. The last line of a text stream does not require a terminating new-line character.

Space characters before a new-line character

Space characters written out to a text stream immediately before a new-line character appear when read in.

Null characters appended to a binary stream

A binary stream is an ordered sequence of characters that can transparently record internal data. An unlimited number of null characters may be appended to data written to a binary stream.

File position in append mode

The file position indicator of an append mode stream is initially positioned at the end of the file.

File buffering

Files are fully buffered or unbuffered depending on the setting of setbuf() and setvbuf(). The default buffer size is set by BUFSIZ in stdio.h.

The existence of zero-length files

A zero-length file, one on which no characters have been written by an output stream, actually exists.

Composing valid filenames

The rules for composing valid filenames are:

File access limits

The same file can be simultaneously open multiple times.

Removing open files

The effect of the remove function on an open file is to make the file inaccessible to other programs or to users. The file remains accessible to the program, and other running programs that have already opened the file, through already open file descriptors, but not through new attempts to open a file with the same name. Once all open file descriptors are closed, the file will be irrevocably gone unless versioning is enabled.

Renaming with a name that exists

If a file with the new name exists prior to a call to the rename function, rename will succeed, overwriting the existing file in the process.

Output of pointer values

The output for %p conversion in the fprintf function is a hex number. The value may be preceded by a ``0x'' prefix if %#p is used.

Input of pointer values

The input for %p conversion in the fscanf function is a number of hex digits interpreted as a pointer. If %#p is used, ``0x'' is used as a prefix. This option is identical to the %x conversion specifier.

Reading ranges

A ``-'' character that is neither the first nor the last character in the scanlist for %[ conversion in the fscanf function is interpreted as a range indicator as long as the character to the left is less than the character to the right of the ``-''. The following example selects all upper-case ASCII characters from ``A'' to ``Z'' inclusive:

   %[A-Z]

File position errors

The errno is set to EBADF or ESPIPE by the fgetpos or ftell function on failure. EINVAL may be generated by the lseek() system call (ftell() and fgetpos() call lseek()).

Messages generated by the perror function

The messages generated by the perror function look like:

   <some user message>: <error message>
The error message is selected, from the list shown below under strerror, depending on the value of errno just before calling perror(). If errno has a value of ``0'' then the first string in the list is used and so on.

Allocating zero memory

The calloc, malloc and realloc functions return a pointer to a zero-sized block if the size requested is zero. For calloc and malloc this is different behavior from the behavior of the functions in libmalloc.a which return a NULL on malloc(0).

The abort function and open and temporary files

When the abort function is executed, the buffers of open and temporary files are flushed, all files are closed, and execution returns to the shell.

The exit function

The exit() function returns the lower byte of its argument to the shell if the value of the argument is other than zero, EXIT_SUCCESS, or EXIT_FAILURE. The shell or the user may interpret this value in any way. Unsuccessful termination is indicated by a return of non-zero. Successful termination is indicated by a return value of zero.

Environment names

The set of environment names is that set exported by the parent process.

The system function

Any UNIX command line that is acceptable to the Bourne Shell can be passed as the string to the system function. The Bourne Shell is assumed to be the command processor and that shell is run as a child process to the program's (that is, parent) process.

The strerror function

The strerror function generates the following messages:

strerror function messages

Number Message Error
1 Operation not permitted EPERM
2 No such file or directory ENOENT
3 No such process ESRCH
4 Interrupted system call EINTR
5 I/O error EIO
6 No such device or address ENXIO
7 Arg list too long E2BIG
8 Exec format error ENOEXEC
9 Bad file number EBADF
10 No child processes ECHILD
11 Resource temporarily unavailable EAGAIN
12 Not enough space ENOMEM
13 Permission denied EACCES
14 Bad address EFAULT
15 Block device required ENOTBLK
16 Device busy EBUSY
17 File exists EEXIST
18 Cross-device link EXDEV
19 No such device ENODEV
20 Not a directory ENOTDIR
21 Is a directory EISDIR
22 Invalid argument EINVAL
23 File table overflow ENFILE
24 Too many open files EMFILE
25 Inappropriate I/O control operation ENOTTY
26 Text file busy ETXTBSY
27 File too large EFBIG
28 No space left on device ENOSPC
29 Illegal seek ESPIPE
30 Read-only file system EROFS
31 Too many links EMLINK
32 Broken pipe EPIPE
33 Argument out of domain EDOM
34 Result too large or too small ERANGE
35 No message of desired type ENOMSG
36 Identifier removed EIDRM
37 Channel number out of range ECHRNG
38 Level 2 not synchronized EL2NSYNC
39 Level 3 halted EL3HLT
40 Level 3 reset EL3RST
41 Link number out of range ELNRNG
42 Protocol driver not attached EUNATCH
43 No CSI structure available ENOCSI
44 Level 2 halted EL2HLT
45 Deadlock situation detected/avoided EDEADLK
46 No record locks available ENOLCK
50 Bad exchange descriptor EBADE
51 Bad request descriptor EBADR
52 Message tables full EXFULL
53 Anode table overflow ENOANO
54 Bad request code EBADRQC
55 Invalid slot EBADSLT
56 File locking deadlock EDEADLOCK
57 Bad font file format EBFONT
60 Not a stream device ENOSTR
61 No data available ENODATA
62 Timer expired ETIME
63 Out of stream resources ENOSR
64 Machine is not on the network ENONET
65 Package not installed ENOPKG
66 Object is remote EREMOTE
67 Link has been severed ENOLINK
68 Advertise error EADV
69 Srmount error ESRMNT
70 Communication error on send ECOMM
71 Protocol error EPROTO
74 Multihop attempted EMULTIHOP
75 Inode is remote ELBIN
76 Cross mount point EDOTDOT
77 Not a data message EBADMSG
78 Filename too long ENAMETOOLONG
79 Value too large for defined data type EOVERFLOW
80 Name not unique on network ENOTUNIQ
81 File descriptor in bad state EBADFD
82 Remote address changed EREMCHG
83 Can not access a needed shared library ELIBACC
84 Accessing a corrupted shared library ELIBBAD
85 .lib section in a.out corrupted ELIBSCN
86 Attempting to link in more shared libraries than system limit ELIBMAX
87 Can not exec a shared library directly ELIBEXEC
88 Illegal byte sequence EILSEQ
89 Function not implemented ENOSYS
90 Operation would block _TCPERR
91 Operation now in progress EINPROGRESS
92 Operation already in progress EALREADY
93 Socket operation on non-socket ENOTSOCK
94 Destination address required EDESTADDRREQ
95 Message too long EMSGSIZE
96 Protocol wrong type for socket EPROTOTYPE
97 Protocol not supported EPROTONOSUPPORT
98 Socket type not supported ESOCKTNOSUPPORT
99 Operation not supported on socket EOPNOTSUPP
100 Protocol family not supported EPFNOSUPPORT
101 Address family not supported by protocol family EAFNOSUPPORT
102 Address already in use EADDRINUSE
103 Cannot assign requested address EADDRNOTAVAIL
104 Network is down ENETDOWN
105 Network is unreachable ENETUNREACH
106 Network dropped connection on reset ENETRESET
107 Software caused connection abort ECONNABORTED
108 Connection reset by peer ECONNRESET
110 Socket is already connected EISCONN
111 Socket is not connected ENOTCONN
112 Cannot send after socket shutdown ESHUTDOWN
113 Too many references: cannot splice ETOOMANYREFS
114 Connection timed out ETIMEDOUT
115 Connection refused ECONNREFUSED
116 Host is down EHOSTDOWN
117 No route to host EHOSTUNREACH
118 Protocol not available ENOPROTOOPT
135 Structure needs cleaning EUCLEAN
137 Not a name file ENOTNAM
138 Not available ENAVAIL
139 Is a name file EISNAM
140 Remote I/O error EREMOTEIO
141 Reserved for future use EINIT
142 Unknown error: 142 EREMDEV
145 Directory not empty ENOTEMPTY
150 Too many symbolic links in path ELOOP
151 Stale NFS file handle ESTALE
152 Restartable system call ERESTART
153 No sleeping in stream head of pipe/FIFO ESTRPIPE
500 Unknown error EIORESID

The time zone

The local time zone (with or without daylight savings) is read from an environment variable called TZ at program runtime. That variable assists in interpreting the system clock. If no such environment variable is set the default is to GMT (non-daylight savings time).

The clock function

The era for the clock function is: January 1 1970 00:00 GMT.


Next topic: Locale-specific behavior
Previous topic: weak

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003