Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

wvfork.cc File Reference

#include <fcntl.h>
#include "wvfork.h"
#include "wvlinklist.h"

Go to the source code of this file.

Defines

#define MAX_FD   sysconf(_SC_OPEN_MAX) + 1

Functions

 DeclareWvList (WvForkCallback)
void add_wvfork_callback (WvForkCallback cb)
 Register a callback to be called during wvfork.

pid_t wvfork (int dontclose1, int dontclose2)
 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_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 (intTable &dontclose)

Variables

WvForkCallbackList callbacks


Define Documentation

#define MAX_FD   sysconf(_SC_OPEN_MAX) + 1
 

Definition at line 26 of file wvfork.cc.

Referenced by wvfork().


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 32 of file wvfork.cc.

References callbacks, and WvForkCallback.

Referenced by WvIStreamList::WvIStreamList().

DeclareWvList WvForkCallback   ) 
 

pid_t wvfork intTable &  dontclose  ) 
 

Definition at line 99 of file wvfork.cc.

References MAX_FD, and wvfork_start().

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

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 52 of file wvfork.cc.

References 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.

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

Definition at line 62 of file wvfork.cc.

References callbacks.

Referenced by WvSubProc::fork(), and wvfork().


Variable Documentation

WvForkCallbackList callbacks
 

Definition at line 29 of file wvfork.cc.

Referenced by add_wvfork_callback(), and wvfork_start().


Generated on Tue Oct 5 01:09:22 2004 for WvStreams by doxygen 1.3.7