wvfork.h File Reference


Detailed Description

Provides support for forking processes.

Definition in file wvfork.h.

#include <unistd.h>
#include "wvscatterhash.h"
#include "wvcallback.h"

Include dependency graph for wvfork.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef WvCallback< void, pid_t > WvForkCallback

Functions

 DeclareWvScatterTable (int)
void add_wvfork_callback (WvForkCallback cb)
 Register a callback to be called during wvfork.
pid_t wvfork_start (int *waitfd)
 wvfork_start is just like fork, except that it will block the parent until the child process closes the waitfd, to avoid race conditions.
pid_t wvfork (int dontclose1=-1, int dontclose2=-1)
 wvfork() just runs fork(), but it closes all file descriptors that are flagged close-on-exec, since we don't necessarily always run exec() after we fork().
pid_t wvfork (intTable &dontclose)


Function Documentation

void add_wvfork_callback ( WvForkCallback  cb  ) 

Register a callback to be called during wvfork.

It will be called (in both parent and child process) after the fork has happened but before wvfork returns. It is passed the return value of the fork.

NOTE: There is no way to undo this operation!

Definition at line 51 of file wvfork.cc.

References add_wvfork_callback().

Referenced by add_wvfork_callback().

pid_t wvfork_start ( int *  waitfd  ) 

wvfork_start is just like fork, except that it will block the parent until the child process closes the waitfd, to avoid race conditions.

For example, wvfork uses it, closing the waitfd only when it is done closing the close-on-exec file descriptors.

Definition at line 81 of file wvfork.cc.

References wvfork_start().

Referenced by wvfork_start().

pid_t wvfork ( int  dontclose1 = -1,
int  dontclose2 = -1 
)

wvfork() just runs fork(), but it closes all file descriptors that are flagged close-on-exec, since we don't necessarily always run exec() after we fork().

..

This fixes the year-old mystery bug where WvTapeBackup caused watchdog reboots because the CHILD process wasn't touching it, and it was already open before the fork()...

Definition at line 71 of file wvfork.cc.

References wvfork().

Referenced by WvResolver::findaddr(), and wvfork().


Generated on Sat Feb 7 13:37:17 2009 for WvStreams by  doxygen 1.5.6