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

wvfork.h

Go to the documentation of this file.
00001 /* -*- Mode: C++ -*- 00002 * Worldvisions Weaver Software: 00003 * Copyright (C) 1997-2002 Net Integration Technologies, Inc. 00004 * 00005 * Provides support for forking processes. 00006 */ 00007 00008 #ifndef __WVFORK_H 00009 #define __WVFORK_H 00010 00011 #include <unistd.h> 00012 #include "wvhashtable.h" 00013 #include "wvcallback.h" 00014 00015 DeclareWvTable(int); 00016 typedef WvCallback<void, pid_t> WvForkCallback; 00017 00018 /** 00019 * Register a callback to be called during wvfork. 00020 * It will be called (in both parent and child process) after the fork has 00021 * happened but before wvfork returns. It is passed the return value of the 00022 * fork. 00023 * 00024 * NOTE: There is no way to undo this operation! 00025 */ 00026 extern void add_wvfork_callback(WvForkCallback cb); 00027 00028 /** 00029 * wvfork_start is just like fork, except that it will block the 00030 * parent until the child process closes the waitfd, to avoid race 00031 * conditions. 00032 * 00033 * For example, wvfork uses it, closing the waitfd only when it is 00034 * done closing the close-on-exec file descriptors. 00035 */ 00036 extern pid_t wvfork_start(int *waitfd); 00037 00038 /** 00039 * wvfork() just runs fork(), but it closes all file descriptors that 00040 * are flagged close-on-exec, since we don't necessarily always run 00041 * exec() after we fork()... 00042 * 00043 * This fixes the year-old mystery bug where WvTapeBackup caused 00044 * watchdog reboots because the CHILD process wasn't touching it, and 00045 * it was already open before the fork()... 00046 */ 00047 extern pid_t wvfork(int dontclose1 = -1, int dontclose2 = -1); 00048 extern pid_t wvfork(intTable &dontclose ); 00049 00050 #endif

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