NAME
kjb_fork - Replace for fork() for use with KJB library.
SYNOPSIS
#include "l/l_sys_lib.h"
Example compile flags (system dependent):
-DLINUX_X86_64 -DLINUX_X86_64_OPTERON -DGNU_COMPILER
-I/home/kobus/include
-L/home/kobus/misc/load/linux_x86_64_opteron -L/usr/lib/x86_64-linux-gnu
-lKJB -lfftw3 -lgsl -lgslcblas -ljpeg -lSVM -lstdc++ -lpthread -lSLATEC -lg2c -lacml -lacml_mv -lblas -lg2c -lncursesw
pid_t kjb_fork(void);
DESCRIPTION
This is a wrapper for fork(). As explained below, it is advisable that
kjb_fork() is used instead of fork() if KJB library IO is used. The main
difference from the library user's point of view is that on error, ERROR is
retured (not -1) with an error message set. This is simply for compatability
with the majority of the KJB routines. A test for a negative result is
perhaps the best way to ensure compatability. A second, very important
difference between fork() and kjb_fork(), is that all file buffers are
flushed before forking. This is very important. If a fork process inherits
unflushed buffers, data can be written twice.
Kjb_fork() also ensures that certain cleanup tasks and signal handling that
should only be in place for the parent are not inherited by the child.
Specifically, it is assumes that the parent handles terminal IO.
It would possible to relax this assumption, but it does not seem worth the
trouble. Every program I have ever written has the parent in charge of
terminal IO. Let me know if this is assumption needs to be relaxed.
RETURNS
On success, kjb_fork() returns the same value as the underlying fork().
IE, it returns the childs process id to the parent, and 0 to the child. On
failure ERROR is returned, with an appropriate error message being set.
-
NOTE
-
This is different than fork() which returns -1 on failure.
DISCLAIMER
This software is not adequatedly tested. It is recomended that
results are checked independantly where appropriate.
AUTHOR
Kobus Barnard
DOCUMENTER
Kobus Barnard
SEE ALSO
is_interactive
,
get_user_id
,
get_group
,
kjb_get_env
,
create_system_command_process
,
kjb_system
,
kjb_system_2
,
kjb_exec
,
kjb_waitpid
,
kjb_waitpid2
,
check_child
,
check_child2
,
reset_cleanup_for_fork
,
add_cleanup_function
,
kjb_cleanup
,
kjb_cleanup_for_abort
,
kjb_optional_abort
,
kjb_abort
,
kjb_exit
,
kjb_exit_2
,
terminate_child_process
,
process_is_alive
,
get_idle_time
,
get_temp_file_name