This appendix describes how to achieve source code compatibility for C language programs in the System V habitat. In addition, it provides a summary of system calls and library functions that differ from the default operating system.
To achieve source code compatibility for the C language programs, alter your shell's PATH environment variable and then compile and link your applications.
When you modify the PATH environment variable, access to the System V habitat works on two levels:
Executing the System V versions of the cc and ld commands causes source code references to system calls and subroutines to be resolved against the libraries in the System V habitat. If a subroutine or system call is not found in the System V habitat, the reference is resolved against the standard default libraries and other libraries that you can specify with the commands. Also, the include file search path is altered so that the System V versions of the system header files (for example, /usr/include files) are used instead of the standard versions.
The library functions that invoke system calls use the system call table to locate the system primitives in the kernel. The base operating system contains several system call tables, including one for System V. The system calls that exhibit System V behavior have entries in the System V partition of the system call table.
When you link your program and your PATH is set for the System V habitat, libsys5 is searched to resolve references to system calls. As Figure B-1 illustrates, the unlink() system call invoked by libsys5 points to an entry in the System V partition of the system call table. This maps to a different area of the kernel than the mapping for the default system unlink() system call.
The cc and ld commands that reside in the System V habitat are shell scripts that, when specified, add several options to the default system cc and ld commands before the commands are executed.
The cc command automatically inserts the -Ipath option on the command line to specify the use of the SVID versions of system header files. For example, the /usr/include file is used instead of the default version. System header files that do not have SVID differences are obtained from the default location.
The cc and ld commands automatically include the following options:
By default, cc dynamically links programs using shared libraries when they exist. The System V habitat provides libsys5.so in addition to libsys5.a to support this feature.
The System V version of the cc and ld commands pass all user-specified command line options to the default system versions of the cc and ld commands. This allows you to create library hierarchies. For example, if your PATH environment variable is set to the System V habitat and your program includes references to math library functions and libloc.a functions located in the /local/lib directory, you can compile the program as follows:
%
cc -non_shared -L/local/lib src.c -lm -lloc
The System V cc command takes the preceding command line and adds the necessary options to search the System V habitat libraries, which are searched prior to the default libraries. It also includes any existing System V header files instead of the standard header files for /usr/include. Hence, if your environment is set to SVID 2, the preceding command line is processed as follows:
/bin/cc -non_shared -L$SVID2PATH/usr/lib -L/local/lib src.c -lm -lloc -lsys5
Using this command line, libraries are searched in the following order:
The libraries that are searched and the order that they are searched in depends on the function you are performing. For more information, see cc(1) and ld(1).
Table B-1 describes the behavior of the system calls in the System V habitat. For a complete explanation of these system calls, refer to the reference pages for each system call. Table B-2 describes the behavior of the library functions in the System V habitat.
See the reference pages for complete descriptions of the system calls and library routines.
System Call | System V Behavior |
longjmp(2) and setjmp(2) | Saves and restores the stack only. |
mknod(2) | Provides the ability to create a directory, regular file, or special file. |
mount(2sv) and umount(2sv) |
Takes different arguments than the default system version
and requires that the
<sys/types.h>
header file is included.
|
open(2) | Specifies that the O_NOCTTY flag is not set by default as it is in the base system. Thus, if the proper conditions exist, an open call to a terminal device will allow the device to become the controlling terminal for the process. |
pipe(2) | Supports a pipe operation on STREAMS-based file descriptors. |
sigaction(2) and signal(2) | Specifies that the kernel pass additional information to the signal handler. This includes passing the reason that the signal was delivered (into the siginfo structure) and the context of the calling process when the signal was delivered into the ucontext structure. |
sigpause(2) | Unblocks the specified signal from the calling process's signal mask and suspends the calling process until a signal is received. The SIGKILL and SIGSTOP signals cannot be reset. |
sigset(2) | Specifies that if the disposition for SIGCHLD is set to SIG_IGN, the calling process's children cannot turn into zombies when they terminate. If the parent subsequently waits for its children, it blocks until all of its children terminate. This operation then returns a value of -1 and sets errno to [ECHILD]. |
unlink(2) | Does not allow users (including superusers) to unlink nonempty directories and sets errno to ENOTEMPTY. It allows superusers to unlink a directory if it is empty. |
Library Functions | System V Behavior |
getcwd(3) |
Gets the name of the current directory.
char *getcwd (char *buffer, int size); |
mkfifo(3) | Supports creation of STREAMS-based FIFO and uses /dev/streams/pipe. |
mktemp(3) | Uses the getpid function to obtain the pid part of the unique name. |
ttyname(3) | Returns a pointer to a string with the pathname that begins with /dev/pts/ when the terminal is a pseudoterminal device. |