bproc_rfork

Name

bproc_rfork -- fork, with the child ending up on a remote node.

Synopsis

#include <sys/bproc.h>

int _bproc_rfork_io (int node, int flags, int port);

int _bproc_rfork (int node, int flags);

int bproc_rfork (int node);

Arguments

node

The node the child should be on.

flags

Flags for VMAdump.

port

The port to BProc should connect back to for I/O forwarding.

Description

The semantics of this function are designed to mimic fork except that the child process created will end up on the node given by the node argument. The process forks a child and that child performs a bproc_move to move itself to the remote node. Combining these two operations in a system call, prevents zombies and SIGCHLDs in the case that the fork is successful but the move is not. On success, this function returns the process ID of the new child process to the parent and zero to the child. On failure it returns -1, and errno is set appropriately.

node is the node the child should be on.

flags can be one of: BPROC_DUMP_LIBS, BPROC_DUMP_EXEC, BPROC_DUMP_OTHER or any combination of them binary OR'd together. If you with to use all of them, you can also use BPROC_DUMP_ALL as a shortcut. These flags tell VMAdump how much of the running process to dump and send to the slave node.

port is the port BProc should connect back to, to handle I/O forwarding. A port value of zero means it assumes I/O forwarding is being done on the existing socket for stdout and stderr only. Any other value and it will try to connect back to that port and open three connections, one for stdout, one for stderr, and one for stdin.

If you use _bproc_rfork or bproc_rfork, port has a default value of 0. If you use bproc_rfork, flags takes a default value that is BPROC_DUMP_EXEC|BPROC_DUMP_OTHER, if you are trying to move to an up node or the master, otherwise it is BPROC_DUMP_EXEC|BPROC_DUMP_LIBS|BPROC_DUMP_OTHER.

Return Value

For the parent process, this will return the pid of the child process.

For the child process, this will return 0.

If there is an error, -1 will be returned to the parent process and there will be no child process.

Errors

EBUSY

No Master