G:/ScriptBasic/source/tools/fork.c File Reference

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
#include <stdarg.h>
#include <errno.h>
#include "winsup.h"
#include "dll_init.h"

Go to the source code of this file.

Defines

#define FORK_WAIT_TIMEOUT   (300 * 1000)
#define dll_data_start   &_data_start__
#define dll_data_end   &_data_end__
#define dll_bss_start   &_bss_start__
#define dll_bss_end   &_bss_end__
#define sync_with_parent(s, hang_self)

Functions

static void stack_base (child_info_fork &ch)
static int fork_copy (PROCESS_INFORMATION &pi, const char *what,...)
static int sync_with_child (PROCESS_INFORMATION &pi, HANDLE subproc_ready, BOOL hang_child, const char *s)
static int resume_child (PROCESS_INFORMATION &pi, HANDLE forker_finished)
static volatile void grow_stack_slack ()
static void * stack_dummy (int here)
int fork ()
int vfork ()

Variables

DWORD NO_COPY chunksize = 0


Define Documentation

#define dll_bss_end   &_bss_end__
 

Definition at line 28 of file fork.c.

Referenced by fork().

#define dll_bss_start   &_bss_start__
 

Definition at line 27 of file fork.c.

Referenced by fork().

#define dll_data_end   &_data_end__
 

Definition at line 26 of file fork.c.

Referenced by fork().

#define dll_data_start   &_data_start__
 

Definition at line 25 of file fork.c.

Referenced by fork().

#define FORK_WAIT_TIMEOUT   (300 * 1000)
 

Definition at line 23 of file fork.c.

Referenced by sync_with_child().

#define sync_with_parent s,
hang_self   ) 
 

Value:

((void) ({ \
  debug_printf ("signalling parent: %s", s); \
  /* Tell our parent we're waiting. */ \
  if (!SetEvent (child_proc_info->subproc_ready)) \
    api_fatal ("fork child - SetEvent failed, %E"); \
  if (hang_self) \
    { \
      /* Wait for the parent to fill in our stack and heap. \
         Don't wait forever here.  If our parent dies we don't want to clog \
         the system.  If the wait fails, we really can't continue so exit.  */ \
      DWORD psync_rc = WaitForSingleObject (child_proc_info->forker_finished, FORK_WAIT_TIMEOUT); \
      switch (psync_rc) \
        { \
        case WAIT_TIMEOUT: \
          api_fatal ("sync_with_parent - WFSO timed out"); \
          break; \
        case WAIT_FAILED: \
          if (GetLastError () == ERROR_INVALID_HANDLE && \
              WaitForSingleObject (child_proc_info->forker_finished, 1) != WAIT_FAILED) \
            break; \
          api_fatal ("sync_with_parent - WFSO failed, fork_finished %p, %E", child_proc_info->forker_finished); \
          break; \
        default: \
          break; \
        } \
      debug_printf ("awake"); \
    } \
  0; \
}))

Definition at line 199 of file fork.c.


Function Documentation

int fork  ) 
 

Definition at line 237 of file fork.c.

References pinfo_list::allocate_pid(), ch, CloseHandle(), pinfo::copysigs(), pinfo::ctty, cygwin_shared, dll_bss_end, dll_bss_start, dll_data_end, dll_data_start, pinfo::domain, dummy(), pinfo::dwProcessId, fflush(), fork_copy(), free(), pinfo::gid, grow_stack_slack(), pinfo::hProcess, pinfo::impersonated, init_child_info(), ISSTATE, pinfo::logsrv, memcpy(), myself, NULL, pinfo::orig_gid, pinfo::orig_uid, shared_info::p, pinfo::pgid, pinfo::pid, pinfo::ppid, PROC_FORK1, pinfo::process_state, pinfo::progname, pinfo::psid, rc, pinfo::real_gid, pinfo::real_uid, res, resume_child(), pinfo::root, pinfo::rootlen, sec_all, sec_none_nih, sec_user(), pinfo::sid, pinfo::sidbuf, stack_base(), stack_dummy(), strcpy(), sync_with_child(), pinfo::token, pinfo::uid, pinfo::umask, and pinfo::username.

Referenced by main(), and vfork().

static int fork_copy PROCESS_INFORMATION &  pi,
const char *  what,
  ...
[static]
 

Definition at line 61 of file fork.c.

References chunksize, and res.

Referenced by fork().

static volatile void grow_stack_slack  )  [static]
 

Definition at line 620 of file fork.c.

References dummy().

Referenced by fork().

static int resume_child PROCESS_INFORMATION &  pi,
HANDLE  forker_finished
[static]
 

Definition at line 172 of file fork.c.

References rc.

Referenced by fork().

static void stack_base child_info_fork ch  )  [static]
 

Definition at line 42 of file fork.c.

References ch, and memset().

Referenced by fork().

static void* stack_dummy int  here  )  [static]
 

Definition at line 231 of file fork.c.

Referenced by fork().

static int sync_with_child PROCESS_INFORMATION &  pi,
HANDLE  subproc_ready,
BOOL  hang_child,
const char *  s
[static]
 

Definition at line 112 of file fork.c.

References FORK_WAIT_TIMEOUT, and rc.

Referenced by fork().

int vfork  ) 
 

Definition at line 638 of file fork.c.

References fork(), and NULL.


Variable Documentation

DWORD NO_COPY chunksize = 0
 

Definition at line 20 of file fork.c.

Referenced by fork_copy().


Generated on Sun Mar 12 23:56:38 2006 for ScriptBasic by  doxygen 1.4.6-NO