POSIX 1003.1 is based on a UNIX operating system standard. A discussion of each of the fundamental POSIX concepts follows.
Note: MVS 5.1 allows more than one process to be created in the same address space. This is an extension of the POSIX process model.
Programs can have permissions that are associated with the ownership of the program rather than with the user running the program. The real user ID and real group ID are associated with the user running the program. The effective user ID and effective group ID, which could be affected by the program, are used to determine the current permissions for the process. The POSIX permission structure is coarser than the structure defined by mainframe security products such as RACF; the ability to create a program with the privileges of its owner is new to MVS. POSIX allows users with appropriate privileges to suppress certain permissions checks; users with such privileges are called super-users.
Some signals cannot be caught. The signal SIGKILL
can be used to
terminate another process without allowing the target process to
intercept termination. Unless the user
has appropriate privileges, a process can send a signal only to other
closely related processes, for instance, ones that it created. MVS
does not have a concept that corresponds to the POSIX signal.
Under MVS, various types of interrupts are handled by a number of
unrelated facilities such as ESTAE
, STIMER
, and
STAX
.
Processes can share files. A locking mechanism allows processes to
cooperate in sharing a file. Filenames may be as long as 1024 bytes
in OpenEdition. Case distinctions are honored in filenames;
calc.c
and Calc.c
reference separate files. This is in
contrast to MVS data sets, which are record-oriented, cannot generally
be shared, and whose names are limited to a small number of uppercase
characters. POSIX files are organized into file systems that are
stored in MVS data sets by OpenEdition. These data sets can be
mounted independently.
/u/fred/calc.c
refers to the file named
calc.c
, in the directory fred
, in the directory u
in
the system root directory. Both special and regular files are
referenced by hierarchical filenames. For example, the pathname for
the user's terminal is /dev/tty
. Each process has a current
working directory that defines a reference point for pathnames. If a
working directory for a process is /u/fred
, the pathname
calc.c
is interpreted as /u/fred/calc.c
. You can read a
directory and write applications that process some or all of the
files in a directory. Neither MVS catalogs nor PDS directories offer
the flexibility and convenience of POSIX directories.
tcflush
is an
interface that is used to discard unread terminal input. A terminal
may be either a physical ASCII asynchronous terminal, such as a
VT-100, or a pseudo-terminal, which is a software emulation of an
asynchronous terminal. OpenEdition supports only pseudo-terminals
created by the TSO OMVS command. When a process writes to an
OpenEdition pseudo-terminal, the output is received by the OMVS
command, which then writes the data to the user's TSO terminal. Input
is handled in the same way. Some POSIX terminal control functions,
such as defining the terminal's baud rate, have no effect on
OpenEdition because they are not meaningful for a pseudo-terminal.
A controlling terminal is a POSIX terminal that controls a set of processes called a session. In a normal UNIX system, a session is started when a user logs in; the controlling terminal is the terminal associated with the login. In OpenEdition, a session is usually started when a user executes the OMVS command.
A session may be divided into several process groups: a foreground process group and one or more background process groups. Processes are generally allowed to send signals only to other processes in their process group. The controlling terminal can use special input sequences to interrupt or halt the processes of the foreground process group. For example, the control-C character causes a SIGINT to be sent to each foreground process. Note that the OMVS command uses the sequence ¢c to replace control-C, which cannot be entered from a 3270 keyboard.
system
and popen
functions,
which can invoke an
OpenEdition command through the shell.
int
variable errno
contains the
number of the most
recent error or warning condition detected by the run-time library.
To use
this value, include the header file <errno.h>
.
<errno.h>
header file contains definitions for the
macro identifiers that name system error status conditions.
When a SAS/C Library function sets an error status by assigning a
nonzero valued to errno
, the calling program can check
for a particular value by using the name defined in <errno.h>
.
The following OpenEdition related, POSIX defined errno
values are defined
in <errno.h>
:
E2BIG
exec
function too large
EAGAIN
EBUSY
EINUSE
)
ECHILD
EDEADLK
EFAULT
EFBIG
EINVAL
EARE
)
EISDIR
ELOOP
EMFILE
ELIMIT
)
EMLINK
EMVSEXPIRE
EMVSINITIAL
EMVSNOTUP
EMVSPASSWORD
ENAMETOOLONG
ENDENT
ENFOUND
)
ENFILE
ENODEV
ENOEXEC
ENOLCK
ENOSYS
ENOTDIR
ENOTEMPTY
ENOTTY
ENXIO
EPERM
EPIPE
EROFS
ESPIPE
EUNSUPP
)
ESRCH
EXDEV
GIO
EDEVICE
)
Note:
In addition to the values listed above,
common SAS/C errno
values are listed in
Chapter 1, "Introduction to the
SAS/C Library," in SAS/C Library Reference, Volume 1 . Also refer to <errno.h>
for socket-related errno
values. For a complete
listing of all errno
values, see the SAS/C Compiler and Library Quick Reference Guide .
Also note that OpenEdition frequently uses a reason code to provide additional information about errors occuring in POSIX functions. See "System Macro Information" in Chapter 1 of SAS/C Library Reference, Volume 1 for information on accessing OpenEdition reason codes.
errno
values
represent OpenEdition internal errors. Contact
IBM Technical Support if you receive one of these errors. These
errno
values are described in more detail in the manual,
OpenEdition Assembler Callable Services.
EIBMCANCELLED
EIBMCONFLICT
EIBMSOCKINUSE
EIBMSOCKOUTOFRANGE
EMVSCATLG
EMVSCVAF
EMVSDYNALC
EMVSPFSFILE
EMVSPFSPERM
EMVSSAF2ERR
EMVSSAFEXTRERR
EOFFLOADBOXDOWN
EOFFLOADBOXERROR
EOFFLOADBOXRESTART
Consult The POSIX.1 Standard: A Programmer's Guide by Fred Zlotnick
(1991, Benjamin/Cummings Publishing) or the POSIX standards for information on
the POSIX errno
values; consult IBM OpenEdition documentation for
information on the EMVS- and EIBM- errno
values.
Because the errno
values resulting from POSIX functions are well
organized and well-defined, the SAS/C Library does not diagnose
many problems that can occur with these functions, even when it
diagnoses similar problems occurring with MVS files. This eases
porting programs from other open systems, since these systems do
not, in general, have library diagnostics. In general, the SAS/C
Library will issue diagnostics for failures of OpenEdition
functionality only when (a) the failure is certainly the result
of programmer error, or (b) the error is so esoteric that diagnosis
is unlikely without a message.
Table 19.1 SAS/C OpenEdition Interfaces
Function Extension | 10031a/1003.2 | Volume
+----------------------------+----------+---------------+--------+ | Process Control Functions | | | | |----------------------------|----------|---------------|--------| | atfork | Yes | | II | |----------------------------|----------|---------------|--------| | execl | | | II | |----------------------------|----------|---------------|--------| | execle | | | II | |----------------------------|----------|---------------|--------| | execlp | | | II | |----------------------------|----------|---------------|--------| | execv | | | II | |----------------------------|----------|---------------|--------| | execve | | | II | |----------------------------|----------|---------------|--------| | execvp | | | II | |----------------------------|----------|---------------|--------| | _exit | | | II | |----------------------------|----------|---------------|--------| | fork | | | II | |----------------------------|----------|---------------|--------| | getpid | | | II | |----------------------------|----------|---------------|--------| | getppid | | | II | |----------------------------|----------|---------------|--------| | oeattach | Yes | | II | |----------------------------|----------|---------------|--------| | oeattache | Yes | | II | |----------------------------|----------|---------------|--------| | times | | | II | |----------------------------|----------|---------------|--------| | w_getpsent | Yes | | II | |----------------------------|----------|---------------|--------| | wait | | | II | |----------------------------|----------|---------------|--------| | waitpid | | | II | |----------------------------|----------|---------------|--------| | Permission Functions | | | | |----------------------------|----------|---------------|--------| | chaudit | Yes | | I | |----------------------------|----------|---------------|--------| | chmod | | | II | |----------------------------|----------|---------------|--------| | chown | | | II | |----------------------------|----------|---------------|--------| | fchaudit | Yes | | II | |----------------------------|----------|---------------|--------| | fchmod | Yes | | I | |----------------------------|----------|---------------|--------| | fchown | Yes | | II | |----------------------------|----------|---------------|--------| | getegid | | | II | |----------------------------|----------|---------------|--------| | geteuid | | | II | |----------------------------|----------|---------------|--------| | getgid | | | II | |----------------------------|----------|---------------|--------| | getgrgid | | | II | |----------------------------|----------|---------------|--------| | getgrnam | | | II | |----------------------------|----------|---------------|--------| | getgroups | | | II | |----------------------------|----------|---------------|--------| | getgroupsbyname | Yes | | II | |----------------------------|----------|---------------|--------| | getlogin | | | II | |----------------------------|----------|---------------|--------| | getpwnam | | | II | |----------------------------|----------|---------------|--------| | getpwuid | | | II | |----------------------------|----------|---------------|--------| | getuid | | | II | |----------------------------|----------|---------------|--------| | initgroups | Yes | | II | |----------------------------|----------|---------------|--------| | __passwd | Yes | | II | |----------------------------|----------|---------------|--------| | setgid | | | II | |----------------------------|----------|---------------|--------| | setgroups | Yes | | II | |----------------------------|----------|---------------|--------| | setuid | | | II | |----------------------------|----------|---------------|--------| | umask | | | II | |----------------------------|----------|---------------|--------| | Signal Functions | | | | |----------------------------|----------|---------------|--------| | alarm | | | I | |----------------------------|----------|---------------|--------| | kill | | | I | |----------------------------|----------|---------------|--------| | ecbsuspend | Yes | | I | |----------------------------|----------|---------------|--------| | oesigsetup | Yes | | I | |----------------------------|----------|---------------|--------| | pause | | | I | |----------------------------|----------|---------------|--------| | sigaction | | | I | |----------------------------|----------|---------------|--------| | sigaddset | | | I | |----------------------------|----------|---------------|--------| | sigdelset | | | I | |----------------------------|----------|---------------|--------| | sigemptyset | | | I | |----------------------------|----------|---------------|--------| | sigfillset | | | I | |----------------------------|----------|---------------|--------| | sigismember | | | I | |----------------------------|----------|---------------|--------| | siglongjmp | | | I | |----------------------------|----------|---------------|--------| | sigpending | | | I | |----------------------------|----------|---------------|--------| | sigprocmask | | | I | |----------------------------|----------|---------------|--------| | sigsetjmp | | | I | |----------------------------|----------|---------------|--------| | sigsuspend | | | I | |----------------------------|----------|---------------|--------| | sleep | | | I | +----------------------------|----------|---------------|--------| | I/O Functions | | | | |----------------------------|----------|---------------|--------| | close | | | I | |----------------------------|----------|---------------|--------| | creat | | | I | |----------------------------|----------|---------------|--------| | dup | | | I | |----------------------------|----------|---------------|--------| | dup2 | | | I | |----------------------------|----------|---------------|--------| | fcntl | | | I | |----------------------------|----------|---------------|--------| | fdopen | | | I | |----------------------------|----------|---------------|--------| | fileno | | | I | |----------------------------|----------|---------------|--------| | fsync | Yes | | I | |----------------------------|----------|---------------|--------| | ftruncate | Yes | | I | |----------------------------|----------|---------------|--------| | lseek | | | I | |----------------------------|----------|---------------|--------| | open | | | I | |----------------------------|----------|---------------|--------| | pipe | | | I | |----------------------------|----------|---------------|--------| | read | | | I | |----------------------------|----------|---------------|--------| | w_ioctl | Yes | | I | |----------------------------|----------|---------------|--------| | write | | | I | |----------------------------|----------|---------------|--------| | Directory Functions | | | | |----------------------------|----------|---------------|--------| | chdir | | | I | |----------------------------|----------|---------------|--------| | closedir | | | I | |----------------------------|----------|---------------|--------| | getcwd | | | I | |----------------------------|----------|---------------|--------| | mkdir | | | I | |----------------------------|----------|---------------|--------| | opendir | | | I | |----------------------------|----------|---------------|--------| | readdir | | | I | |----------------------------|----------|---------------|--------| | rewinddir | | | I | |----------------------------|----------|---------------|--------| | rmdir | | | I | |----------------------------|----------|---------------|--------| | File Utilities | | | | |----------------------------|----------|---------------|--------| | access | | | I | |----------------------------|----------|---------------|--------| | fstat | | | I | |----------------------------|----------|---------------|--------| | link | | | I | |----------------------------|----------|---------------|--------| | lstat | Yes | | I | |----------------------------|----------|---------------|--------| | mkfifo | | | I | +----------------------------|----------|---------------|--------| | File Utilities | | | | |----------------------------|----------|---------------|--------| | mknod | Yes | | I | |----------------------------|----------|---------------|--------| | readlink | Yes | | I | |----------------------------|----------|---------------|--------| | rename | | | I | |----------------------------|----------|---------------|--------| | stat | | | I | |----------------------------|----------|---------------|--------| | symlink | Yes | | I | |----------------------------|----------|---------------|--------| | unlink | | | I | |----------------------------|----------|---------------|--------| | utime | | | I | |----------------------------|----------|---------------|--------| | Terminal Functions | | | | |----------------------------|----------|---------------|--------| | cfgetispeed | | | II | |----------------------------|----------|---------------|--------| | cfgetospeed | | | II | |----------------------------|----------|---------------|--------| | cfsetispeed | | | II | |----------------------------|----------|---------------|--------| | cfsetospeed | | | II | |----------------------------|----------|---------------|--------| | ctermid | | | I | |----------------------------|----------|---------------|--------| | isatty | | | I | |----------------------------|----------|---------------|--------| | tcdrain | | | II | |----------------------------|----------|---------------|--------| | tcflow | | | II | |----------------------------|----------|---------------|--------| | tcflush | | | II | |----------------------------|----------|---------------|--------| | tcgetattr | | | II | |----------------------------|----------|---------------|--------| | tcsendbreak | | | II | |----------------------------|----------|---------------|--------| | tcsetattr | | | II | |----------------------------|----------|---------------|--------| | ttyname | | | I | |----------------------------|----------|---------------|--------| | Sessions and Process Groups Functions | | | |---------------------------------------|---------------|--------| | getpgrp | | | II | |----------------------------|----------|---------------|--------| | setpgid | | | II | |----------------------------|----------|---------------|--------| | setsid | | | II | |----------------------------|----------|---------------|--------| | tcgetpgrp | | | II | |----------------------------|----------|---------------|--------| | tcsetpgrp | | | II | |----------------------------|----------|---------------|--------| | Environmental Interfaces | | | | |----------------------------|----------|---------------|--------| | clearenv | Yes | | I | |----------------------------|----------|---------------|--------| | fpathconf | | | II | |----------------------------|----------|---------------|--------| | Environmental Interfaces | | | | |----------------------------|----------|---------------|--------| | getdtablesize | Yes | | II | |----------------------------|----------|---------------|--------| | getenv | | | I | |----------------------------|----------|---------------|--------| | pathconf | | | II | |----------------------------|----------|---------------|--------| | pclose | Yes | | I | |----------------------------|----------|---------------|--------| | popen | Yes | | I | |----------------------------|----------|---------------|--------| | setenv | Yes | | I | |----------------------------|----------|---------------|--------| | sysconf | | | II | |----------------------------|----------|---------------|--------| | system | Yes | | I | |----------------------------|----------|---------------|--------| | uname | | | II | |----------------------------|----------|---------------|--------| | Miscellaneous Functions | | | | |----------------------------|----------|---------------|--------| | mount | Yes | | II | |----------------------------|----------|---------------|--------| | tzset | | | I | |----------------------------|----------|---------------|--------| | umount | Yes | | II | |----------------------------|----------|---------------|--------| | w_getmntent | Yes | | II | |----------------------------|----------|---------------|--------| | w_statfs | Yes | | II | +----------------------------|----------|---------------|--------+
_access
_close
_fcntl
_fsync
_lseek
_open
_read
_rename
_unlink
_write
OpenEdition also supports mixed mode programs that combine base MVS and POSIX functionality, for instance, to enable a user shell command to write a VSAM file or to enable a TSO command to create new processes and communicate with the processes through pipes. The rest of this section discusses the interaction between MVS and POSIX.
fork
system call creates a duplicate of a process, not all of
the information is copied to the new address space.
Information that is copied includes:
fork
has the following consequences:
fork
. Most of these signals cannot occur
in an address space created by fork
.
fork
can define atfork
exits
to take the appropriate action before and after a call to fork
.
exec
functions is called (execl
,
execle
, execlp
, execv
, execve
, or
execvp
),
OpenEdition terminates
the current process and begins a new process. Every task in the
address space is terminated. A new job step is inserted to
reinitialize the address space and run the specified program.
The new program inherits many of the OpenEdition attributes of its caller, such as open files, blocked signals, current alarm status, and process id. The new program does not inherit MVS-oriented information such as DD statements (other than STEPLIB) and blocking of non-OpenEdition signals or dynamically loaded modules.
The only allocated storage in the new process is associated
with the program's arguments and environment variables. Any
information to be passed to a program called by one of the exec
functions must
be passed in argument or environment variables. You may want to
consider using the oeattach
function, rather than
fork
and exec
, if you want to share storage with a
child process.
Because the program called by the exec
function
begins execution with no DD
statements, problems can arise while accessing the transient library.
If the SAS/C transient library is not in linklist or LPALIB, you may
need to define the ddn_CTRANS environment variable before calling
an exec function to execute a SAS/C program. See "Executing C
Programs" in SAS/C Compiler and Library User's Guide, Fourth Edition for more information.
Table 19.2 Standard POSIX Data Types
Name Type Header File Use
cc_t char <termios.h> Terminal control character clock_t double <time.h> Clock tick time unit dev_t unsigned int <sys/types.h> Device number gid_t unsigned int <sys/types.h> Group ID ino_t unsigned long <sys/types.h> File serial number mode_t unsigned long <sys/types.h File access mode nlink_t int <sys/types.h> File link count off_t long <sys/types.h> Type for lseek position pid_t unsigned int <sys/types.h> Process ID or process group ID size_t int <sys/types.h> Result of sizeof operator speed_t unsigned char <termios.h> Terminal I/O speed ssize_t int <sys/types.h> Signed equivalent of size_t tcflag_t int <termios.h> Terminal control flag time_t double <time.h> Elapsed time unit uid_t unsigned int <sys/types.h> User ID
Refer to Chapter 3, "I/O Functions," in SAS/C Library Reference, Volume 1 for information on using
environment variables to replace DD statements in programs called by
exec*
.
According to POSIX, a process terminates abnormally as the result of receiving a signal for which the default action is process termination. Abnormal termination is identified only by the signal name.
From an MVS perspective, any abnormal termination resulting from a
POSIX signal causes an ABEND with a system completion code of EC6
.
The signal number can be extracted from the MVS reason code associated
with the ABEND.
From a POSIX perspective, the situation is more complex. If a process
terminates as the result of an ABEND that is not the direct result of
a POSIX signal, the behavior depends on actions of the run-time
library. If the run-time library's ABEND handling is not active due to
the use of the =nohtsig
option, or if the library is incapable
of handling the ABEND because, for example, library control blocks
have been corrupted, the ABEND can complete. OpenEdition interprets
the completion by ABEND as termination by SIGKILL
.
If the library can handle the ABEND,
the ABEND is transformed into an OpenEdition signal: SIGABRT
for a
user ABEND, or SIGABND
for a system ABEND. If the program has
defined a handler for the signal, control is passed to the handler.
Otherwise, the library completes termination by sending the
appropriate signal to itself; this causes the process status, as seen
by the parent process, to indicate that signal.
When termination results from a program check such as an invalid
memory access, the library's traceback may show either the traditional
0Cx
ABEND code or an EC6
ABEND. For programs that use OpenEdition
signal handling, it is difficult to predict which ABEND code will be
reported.
oeattach
and oeattache
functions allow you to create a child
process that runs
in the same address space as the caller. Processes created in this
manner do not obey all the normal POSIX rules for processes. In
particular:
setuid
or setgid
program unless the program's
specified user ID or group ID is the same as the current user ID or
group ID.
exec
function, a new subtask of the
parent process is created, that is, the exec
call does not terminate
the address space. An attempt to exec
a
setuid
or
setgid
program
that does not match the current user ID or group ID will fail.
oeattach
.
oeattach
is called from a TSO address space,
the child process
can read from and write to the user's TSO terminal. However, some
other TSO-related functionality is unavailable, such as TSO external
scope environment variables and the tso:
feature of the system
function.
errno
to EMVSNOTUP
,
and
returns.
There are a few functions for which the 1003.1 standard does not
specify a way to fail because it is impossible for the function to
fail in the UNIX environment. For instance, in the UNIX environment,
getpid
cannot fail, because every program has a process ID. In
MVS, if OpenEdition is not installed or has failed, it is impossible
to obtain a process ID. In these cases, the library issues an ABEND
user 1230.
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.