Added support for CREATE_SUSPENDED flag in CreateProcess.

diff --git a/server/process.c b/server/process.c
index 17fa8cc..f5ce220 100644
--- a/server/process.c
+++ b/server/process.c
@@ -70,6 +70,7 @@
     process->suspend         = 0;
     process->console_in      = NULL;
     process->console_out     = NULL;
+    process->init_event      = NULL;
     process->info            = NULL;
     gettimeofday( &process->start_time, NULL );
 
@@ -87,6 +88,13 @@
     memcpy( process->info->cmdline, cmd_line, len );
     process->info->cmdline[len] = 0;
 
+    /* get the init done event */
+    if (req->event != -1)
+    {
+        if (!(process->init_event = get_event_obj( parent, req->event, EVENT_MODIFY_STATE )))
+            goto error;
+    }
+
     /* set the process console */
     if (req->create_flags & CREATE_NEW_CONSOLE)
     {
@@ -120,7 +128,6 @@
 
  error:
     free_console( process );
-    if (process->info) free( process->info );
     if (process->handles) release_object( process->handles );
     release_object( process );
     return NULL;
@@ -139,6 +146,7 @@
     req.hstdin       = -1;
     req.hstdout      = -1;
     req.hstderr      = -1;
+    req.event        = -1;
     req.cmd_show     = 0;
     req.env_ptr      = NULL;
     if ((process = create_process( NULL, &req, "", 1 )))
@@ -165,6 +173,7 @@
     if (process->prev) process->prev->next = process->next;
     else first_process = process->next;
     if (process->info) free( process->info );
+    if (process->init_event) release_object( process->init_event );
 }
 
 /* dump a process on stdout for debugging purposes */
@@ -369,6 +378,21 @@
     free( info );
 }
 
+/* signal the end of the process initialization */
+DECL_HANDLER(init_process_done)
+{
+    struct process *process = current->process;
+    if (!process->init_event)
+    {
+        fatal_protocol_error( current, "init_process_done: no event\n" );
+        return;
+    }
+    set_event( process->init_event );
+    release_object( process->init_event );
+    process->init_event = NULL;
+    if (current->suspend + current->process->suspend > 0) stop_thread( current );
+}
+
 /* open a handle to a process */
 DECL_HANDLER(open_process)
 {
diff --git a/server/process.h b/server/process.h
index b141dc9..08edd0b 100644
--- a/server/process.h
+++ b/server/process.h
@@ -34,6 +34,7 @@
     int                  suspend;         /* global process suspend count */
     struct object       *console_in;      /* console input */
     struct object       *console_out;     /* console output */
+    struct event        *init_event;      /* event for init done */
     struct new_process_request *info;     /* startup info (freed after startup) */
 };
 
diff --git a/server/request.h b/server/request.h
index c111d4d..6ee07e6 100644
--- a/server/request.h
+++ b/server/request.h
@@ -65,6 +65,7 @@
 DECL_HANDLER(new_thread);
 DECL_HANDLER(set_debug);
 DECL_HANDLER(init_process);
+DECL_HANDLER(init_process_done);
 DECL_HANDLER(init_thread);
 DECL_HANDLER(get_thread_buffer);
 DECL_HANDLER(terminate_process);
@@ -142,6 +143,7 @@
     { (void(*)())req_new_thread, sizeof(struct new_thread_request) },
     { (void(*)())req_set_debug, sizeof(struct set_debug_request) },
     { (void(*)())req_init_process, sizeof(struct init_process_request) },
+    { (void(*)())req_init_process_done, sizeof(struct init_process_done_request) },
     { (void(*)())req_init_thread, sizeof(struct init_thread_request) },
     { (void(*)())req_get_thread_buffer, sizeof(struct get_thread_buffer_request) },
     { (void(*)())req_terminate_process, sizeof(struct terminate_process_request) },
diff --git a/server/thread.c b/server/thread.c
index 89fd690..1861fc9 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -318,7 +318,8 @@
 /* stop a thread (at the Unix level) */
 void stop_thread( struct thread *thread )
 {
-    if (!thread->unix_pid) return;
+    /* can't stop a thread while initialisation is in progress */
+    if (!thread->unix_pid || thread->process->init_event) return;
     /* first try to attach to it */
     if (!thread->attached)
         if (attach_thread( thread )) return;  /* this will have stopped it */
diff --git a/server/trace.c b/server/trace.c
index 098b3c2..1af1367 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -52,6 +52,7 @@
     fprintf( stderr, " hstdin=%d,", req->hstdin );
     fprintf( stderr, " hstdout=%d,", req->hstdout );
     fprintf( stderr, " hstderr=%d,", req->hstderr );
+    fprintf( stderr, " event=%d,", req->event );
     fprintf( stderr, " cmd_show=%d,", req->cmd_show );
     fprintf( stderr, " env_ptr=%p,", req->env_ptr );
     fprintf( stderr, " cmdline=\"%s\"", req->cmdline );
@@ -96,6 +97,11 @@
     fprintf( stderr, " cmdline=\"%s\"", req->cmdline );
 }
 
+static void dump_init_process_done_request( struct init_process_done_request *req )
+{
+    fprintf( stderr, " dummy=%d", req->dummy );
+}
+
 static void dump_init_thread_request( struct init_thread_request *req )
 {
     fprintf( stderr, " unix_pid=%d,", req->unix_pid );
@@ -762,6 +768,7 @@
     (dump_func)dump_new_thread_request,
     (dump_func)dump_set_debug_request,
     (dump_func)dump_init_process_request,
+    (dump_func)dump_init_process_done_request,
     (dump_func)dump_init_thread_request,
     (dump_func)dump_get_thread_buffer_request,
     (dump_func)dump_terminate_process_request,
@@ -835,6 +842,7 @@
     (dump_func)dump_new_thread_reply,
     (dump_func)0,
     (dump_func)dump_init_process_reply,
+    (dump_func)0,
     (dump_func)dump_init_thread_reply,
     (dump_func)0,
     (dump_func)0,
@@ -908,6 +916,7 @@
     "new_thread",
     "set_debug",
     "init_process",
+    "init_process_done",
     "init_thread",
     "get_thread_buffer",
     "terminate_process",