ndrx_fork — Fork the Enduro/X client or server
#include <atmi.h>
pid_t ndrx_fork(void);
For XATMI client link with -latmiclt -latmi -lubf -lnstd -lpthread -lrt -lm
For XATMI server link with -latmisrv|-latmisrvnomain|-latmisrvinteg -latmi -lubf -lnstd -lpthread -lrt -lm
When doing forking with the XATMI binaries (either clients or servers), the special care shall be taken when process is about to copy it self. In case if XATMI server process want’s to copy it self, the child copy shall close any queues and other resources used by parent’s XATMI server. Thus one of the tasks of ndrx_fork() is to close server resources after the forking the XATMI servers.
In standard situation when client process is about to fork, it should perform tpterm(3) then perform ndrx_fork(3) and do tpinit(3) back on either in parent or child or both. In this scenario standard fork(3) can be used too, if poller is other than SystemV.
Also ndrx_fork() is recommended for general purpose, because after the fork, child process logger PIDs are updated.
In case if for IPC transport is SystemV poller, ndrx_fork() is mandatory for operating systems other than AIX and Solaris. ndrx_fork() must be used by both XATMI clients and servers, because SystemV mode uses auxiliary threads to support real time operations, thus before forking threads must be terminated, and the restored properly back for the parent process (child performs fresh init back on if XATMI IPC operations are used). The AIX and Solaris properly supports pthread_atfork(), so ndrx_fork() is not mandatory for these operating systems.
If developer cannot replace designed fork() with ndrx_fork() (i.e. it is used in library), then developer may use:
functions and either call them manually after the fork or register them with pthread_atfork() function which automatically invokes them in proper order when fork() call is performed.