Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)

fork(2) OSS System Calls Reference Manual
Sharing Guardian Files
After a successful call to the fork() function, the initial position within an EDIT file (file code
101) in the Guardian file system (a file in /G) that was opened by a call to the OSS open() func-
tion is the same for both the parent and child processes. However, the position is not shared; that
is, changing the position used by one process does not change the position used by the other pro-
cess.
Floating-Point Data
If the parent process uses IEEE floating-point data, the child process inherits all of the floating-
point register contents of the parent process and any computation started before the fork() func-
tion call completes in the child process. The contents of the status and control register are also
inherited.
Use From a Threaded Application
The thread-aware version of the fork( ) function call creates a new process from the current
thread.
NOTES
To use the fork() functionality in a threaded application that uses the Standard POSIX Threads
library, see spt_fork(2).
To use this function in a threaded application that uses the POSIX User Thread Model library on
systems running H06.21 or later RVUs or J06.10 or later RVUs, you must perform all of the fol-
lowing tasks to make the function thread-aware in a multi-threaded application:
Compile the application using the _PUT_MODEL_ feature test macro or equivalent
compiler command option.
Link the application to the zputdll library (/G/system/zdllnnn/zputdll).
On systems running H06.24 or later H-series RVUs or J06.13 or later J-series RVUs, you can use
this function with 32-bit or 64-bit threaded applications.
To use this function in a 32-bit threaded application on systems running H06.24 or later RVUs or
J06.13 or later RVUs, perform the same tasks (described above) used to make the function
thread-aware in a multi-threaded application on systems running H06.21/J06.10 or later RVUs.
To use this function in a 64-bit threaded application on systems running H06.24 or later RVUs or
J06.13 or later RVUs, you must perform all of the following tasks to make the function thread-
aware in a multi-threaded application:
Compile the application using the _PUT_MODEL_ feature test macro or equivalent
compiler command option.
Compile the application using the -Wlp64 compiler command option.
Link the application to the yputdll library (/G/system/zdllnnn/yputdll).
For detailed information about writing multi-threaded and 64-bit applications for the Open Sys-
tem Services environment, see the Open System Services Programmer’s Guide.
RETURN VALUES
Upon successful completion, the fork( ) function returns the value 0 (zero) to the child process
and returns the PID of the child process to the parent process. If the fork() function fails, the
value -1 is returned to the parent process, no child process is created, and errno is set to indicate
the error.
322 Hewlett-Packard Company 527186-023