You can call standard UNIX/POSIX functions from z/OS UNIX programs and from traditional z/OS COBOL programs by using the CALL literal statement. These functions are part of Language Environment.
Because these are C functions, you must pass arguments BY VALUE. Pass character strings as BY VALUE pointers that point to null-terminated strings. You must use the compiler options NODYNAM and PGMNAME(LONGMIXED) when you compile programs that call these functions.
You can call the fork(), exec(), and spawn() functions from a COBOL program or from a non-COBOL program in the same process as COBOL programs. However, be aware of these restrictions:
The exec() and spawn() functions start a new Language Environment enclave in the new UNIX process. Therefore the target program of the exec() or spawn() function is a main program, and all COBOL programs in the process start in initial state with all files closed.
Sample code for calling some of the POSIX routines is provided in the SIGYSAMP data set.
| Purpose | Sample | Functions used |
|---|---|---|
| Shows how to use some of the file and directory routines | IGYTFL1 |
|
| Shows how to use the iconv routines to convert data | IGYTCNV |
|
| Shows the use of the exec() routine to run a new program along with other process-related routines | IGYTEXC, IGYTEXC1 |
|
| Shows how to get the errno value | IGYTERNO, IGYTGETE |
|
| Shows the use of the interprocess communication message routines | IGYTMSQ, IGYTMSQ2 |
|