0001 NDRX_FORK(3)
0002 ============
0003 :doctype: manpage
0004
0005
0006 NAME
0007 ----
0008 ndrx_fork - Fork the Enduro/X client or server
0009
0010
0011 SYNOPSIS
0012 --------
0013 #include <atmi.h>
0014
0015 pid_t ndrx_fork(void);
0016
0017 For XATMI client link with '-latmiclt -latmi -lubf -lnstd -lpthread -lrt -lm'
0018
0019 For XATMI server link with '-latmisrv|-latmisrvnomain|-latmisrvinteg -latmi -lubf -lnstd -lpthread -lrt -lm'
0020
0021 DESCRIPTION
0022 -----------
0023 When doing forking with the XATMI binaries (either clients or servers), the special
0024 care shall be taken when process is about to copy it self. In case if XATMI
0025 server process want's to copy it self, the child copy shall close any queues and
0026 other resources used by parent's XATMI server. Thus one of the tasks of
0027 *ndrx_fork()* is to close server resources after the forking the XATMI servers.
0028
0029 In standard situation when client process is about to fork, it should perform
0030 *tpterm(3)* then perform *ndrx_fork(3)* and do *tpinit(3)* back on either in
0031 parent or child or both. In this scenario standard *fork(3)* can be used too,
0032 if poller is other than SystemV.
0033
0034 Also *ndrx_fork()* is recommended for general purpose, because after the fork,
0035 child process logger PIDs are updated.
0036
0037 In case if for IPC transport is SystemV poller, *ndrx_fork()* is mandatory for
0038 operating systems other than AIX and Solaris. *ndrx_fork()* must be used by
0039 both XATMI clients and servers, because SystemV mode uses auxiliary
0040 threads to support real time operations, thus before forking threads must be
0041 terminated, and the restored properly back for the parent process (child performs
0042 fresh init back on if XATMI IPC operations are used).
0043 The AIX and Solaris properly supports pthread_atfork(), so *ndrx_fork()* is
0044 not mandatory for these operating systems.
0045
0046 If developer cannot replace designed *fork()* with *ndrx_fork()* (i.e. it is used
0047 in library), then developer may use:
0048
0049 . *ndrx_atfork_prepare(3)* - parent calls before forking
0050
0051 . *ndrx_atfork_parent(3)* - called by parent after forking
0052
0053 . *ndrx_atfork_child(3)* - called by child after forking
0054
0055 functions and either call them manually after the fork or register them with
0056 *pthread_atfork()* function which automatically invokes them in proper order
0057 when fork() call is performed.
0058
0059
0060
0061 RETURN VALUE
0062 ------------
0063 On success, *ndrx_fork()* returns 0 for child process, and pid (>0) for the parent
0064 process. In case of failure -1 is returned.
0065
0066
0067 ERRORS
0068 ------
0069 See *fork()* system calls errors.
0070
0071 EXAMPLE
0072 -------
0073 See *cpmsrv/cltexec.c* for sample code.
0074
0075 BUGS
0076 ----
0077 Report bugs to support@mavimax.com
0078
0079 SEE ALSO
0080 --------
0081 *ndrx_atfork_prepare(3)* *ndrx_atfork_parent(3)* *ndrx_atfork_child(3)*
0082
0083
0084 COPYING
0085 -------
0086 (C) Mavimax, Ltd
0087