From 0667782720a6d3b5c0718a8ac9af4e84e88a6428 Mon Sep 17 00:00:00 2001 From: Gary Williams Date: Tue, 13 Apr 1999 21:34:00 +0000 Subject: [PATCH] add section for NT to create processes --- servers/slapd/tools/ldif2ldbm.c | 51 ++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/servers/slapd/tools/ldif2ldbm.c b/servers/slapd/tools/ldif2ldbm.c index 5dda59d83c..d958721b7f 100644 --- a/servers/slapd/tools/ldif2ldbm.c +++ b/servers/slapd/tools/ldif2ldbm.c @@ -8,7 +8,9 @@ #include #include +#ifdef HAVE_SYS_PARAM_H #include +#endif #include "ldapconfig.h" #include "../slap.h" @@ -28,6 +30,10 @@ static char *inputfile; static int maxkids = 1; static int nkids; +#ifdef WIN32 +time_t starttime; +#endif + static void usage( char *name ) { @@ -271,9 +277,50 @@ main( int argc, char **argv ) slap_destroy(); - exit( 0 ); + return( 0 ); } +#ifdef WIN32 + +static HANDLE processes[MAXIMUM_WAIT_OBJECTS]; +static int nprocesses=0; + +static void +fork_child( char *prog, char *args[] ) +{ + PROCESS_INFORMATION proc_info; + PROCESS_INFORMATION *pinfo = &proc_info; + + int i = 0; + char cmdLine[2048]; + memset( cmdLine, 0, sizeof(cmdLine) ); + strcpy( cmdLine, prog ); + while ( args[i] != NULL ); + { + strcat( cmdLine, " " ); + strcat( cmdLine, args[i] ); + } + + if ( !CreateProcess( NULL, cmdLine, NULL, NULL, + TRUE, CREATE_NEW_CONSOLE, + NULL, NULL, NULL, pinfo ) ) + { + fprintf( stderr, "Could not create %s: ", prog ); + perror( "CreateProcess" ); + exit (-1); + } + processes[nprocesses] = proc_info.hProcess; + nprocesses++; +} + +static void +wait4kids( int nkidval ) +{ + WaitForMultipleObjects( nprocesses, processes, TRUE, INFINITE ); +} + +#else + static void fork_child( char *prog, char *args[] ) { @@ -328,3 +375,5 @@ wait4kids( int nkidval ) } } } + +#endif -- 2.39.5