For a namespace clean function, implement
_fork
, otherwise implement
fork
. The implementation of this
functionality will be tightly bound to any operating
infrastructure for handling multiple processes.
A minimal implementation, such as that for bare metal coding, only offers a single user thread of control. It is thus impossible to start a new process, so this function always fails.
#include <errno.h> #undef errno extern int errno; int _fork () { errno = EAGAIN; return -1; /* Always fails */ } /* _fork () */
The choice of errno
is again somewhat
arbitrary. However no value for "no processes available" is
provided, and EAGAIN
is the closest in meaning
to this.