2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
6 * Provides support for forking processes.
18 #include "wvscatterhash.h"
21 DeclareWvScatterTable(int);
22 typedef wv::function
<void(pid_t
)> WvForkCallback
;
25 * Register a callback to be called during wvfork.
26 * It will be called (in both parent and child process) after the fork has
27 * happened but before wvfork returns. It is passed the return value of the
30 * NOTE: There is no way to undo this operation!
32 extern void add_wvfork_callback(WvForkCallback cb
);
35 * wvfork_start is just like fork, except that it will block the
36 * parent until the child process closes the waitfd, to avoid race
39 * For example, wvfork uses it, closing the waitfd only when it is
40 * done closing the close-on-exec file descriptors.
42 extern pid_t
wvfork_start(int *waitfd
);
45 * wvfork() just runs fork(), but it closes all file descriptors that
46 * are flagged close-on-exec, since we don't necessarily always run
47 * exec() after we fork()...
49 * This fixes the year-old mystery bug where WvTapeBackup caused
50 * watchdog reboots because the CHILD process wasn't touching it, and
51 * it was already open before the fork()...
53 extern pid_t
wvfork(int dontclose1
= -1, int dontclose2
= -1);
54 extern pid_t
wvfork(intTable
&dontclose
);