Previous Topic Next topic Print topic


COBRT096 Invalid use of fork() (Fatal)

You have called the operating system's fork() API in a process that has called COBOL functionality, or has multiple threads, and then called some COBOL functionality in the child process.

If a process has used COBOL functionality, it can only safely call fork() if the child then safely calls one of the exec() set of APIs. If an error occurs in the child, it should call _exit(), not exit().

When the fork() API is called, the operating system only creates one thread in the child process. If the parent had multiple threads at the time of the fork(), thread synchronisation objects, such as mutexes, may have been locked in another thread, which could lead to deadlocks in the child if the child used those thread synchronisation objects.

The child process can only call COBOL functionality if all of the following are true:
  • The parent has a single thread when the fork() API is called.
  • The parent process does not call any COBOL functionality, either before or after the fork().
  • The child process calls fork().
Previous Topic Next topic Print topic