XSocket API  2.0
XIA Socket Library
Functions
Xfork.c File Reference

Xfork() - create a child process. More...

#include "Xsocket.h"

Functions

int Xfork (void)
 Creates a new process by duplicating the calling process. More...
 

Function Documentation

int Xfork ( void  )

This function must be used rather than the standard fork() call when uisng Xsockets. Because all of the XIA code resides in user space, we don't get the correct behavior from systems calls that affect the kernel. Xfork() wraps the system fork() call so that correct internal socket state is maintained. This prevents issues such as calling Xclose() in a child process also closing the same socket in the parent process.

Note
See the man page for the standard fork() call for more details.
Returns
On success, the PID of the child process is returned in the parent, and 0 is returned in the child.
-1 on failure to the parent. No child process is created, and errno is set appropriately.