Moved the fields that depends on startup info from the init_process
request to get_startup_info.

diff --git a/server/console.c b/server/console.c
index 871a66e..bbadc1b 100644
--- a/server/console.c
+++ b/server/console.c
@@ -362,6 +362,7 @@
 	    }
 	    release_object( console );
 	}
+        else clear_error();  /* ignore error */
     }
     /* otherwise, if parent has a console, attach child to this console */
     if (!done && parent->console)
diff --git a/server/process.c b/server/process.c
index 863c415..ad3d7ec 100644
--- a/server/process.c
+++ b/server/process.c
@@ -92,7 +92,7 @@
     struct object       obj;          /* object header */
     struct list         entry;        /* entry in list of startup infos */
     int                 inherit_all;  /* inherit all handles from parent */
-    int                 create_flags; /* creation flags */
+    unsigned int        create_flags; /* creation flags */
     int                 unix_pid;     /* Unix pid of new process */
     obj_handle_t        hstdin;       /* handle for stdin */
     obj_handle_t        hstdout;      /* handle for stdout */
@@ -219,43 +219,6 @@
     }
 }
 
-/* set the console and stdio handles for a newly created process */
-static int set_process_console( struct process *process, struct thread *parent_thread,
-                                struct startup_info *info, struct init_process_reply *reply )
-{
-    if (info)
-    {
-        if (!(process->create_flags & (DETACHED_PROCESS | CREATE_NEW_CONSOLE)))
-        {
-            /* FIXME: some better error checking should be done...
-             * like if hConOut and hConIn are console handles, then they should be on the same
-             * physical console
-             */
-            inherit_console( parent_thread, process, info->inherit_all ? info->hstdin : 0 );
-        }
-        if (!info->inherit_all && !(process->create_flags & CREATE_NEW_CONSOLE))
-        {
-            reply->hstdin  = duplicate_handle( parent_thread->process, info->hstdin, process,
-                                               0, TRUE, DUPLICATE_SAME_ACCESS );
-            reply->hstdout = duplicate_handle( parent_thread->process, info->hstdout, process,
-                                               0, TRUE, DUPLICATE_SAME_ACCESS );
-            reply->hstderr = duplicate_handle( parent_thread->process, info->hstderr, process,
-                                               0, TRUE, DUPLICATE_SAME_ACCESS );
-        }
-        else
-        {
-            reply->hstdin  = info->hstdin;
-            reply->hstdout = info->hstdout;
-            reply->hstderr = info->hstderr;
-        }
-    }
-    else reply->hstdin = reply->hstdout = reply->hstderr = 0;
-    /* some handles above may have been invalid; this is not an error */
-    if (get_error() == STATUS_INVALID_HANDLE ||
-        get_error() == STATUS_OBJECT_TYPE_MISMATCH) clear_error();
-    return 1;
-}
-
 /* create a new process and its main thread */
 struct thread *create_process( int fd )
 {
@@ -288,7 +251,6 @@
     process->exe.dbg_size    = 0;
     process->exe.namelen     = 0;
     process->exe.filename    = NULL;
-    process->group_id        = 0;
     process->token           = token_create_admin();
     list_init( &process->thread_list );
     list_init( &process->locks );
@@ -298,7 +260,7 @@
     gettimeofday( &process->start_time, NULL );
     list_add_head( &process_list, &process->entry );
 
-    if (!(process->id = alloc_ptid( process ))) goto error;
+    if (!(process->id = process->group_id = alloc_ptid( process ))) goto error;
     if (!(process->msg_fd = create_anonymous_fd( &process_fd_ops, fd, &process->obj ))) goto error;
 
     /* create the main thread */
@@ -341,7 +303,7 @@
 }
 
 /* initialize the current process and fill in the request */
-static struct startup_info *init_process( struct init_process_reply *reply )
+static size_t init_process(void)
 {
     struct process *process = current->process;
     struct thread *parent_thread = NULL;
@@ -353,7 +315,7 @@
         if (info->thread)
         {
             fatal_protocol_error( current, "init_process: called twice?\n" );
-            return NULL;
+            return 0;
         }
         parent_thread = info->owner;
         parent = parent_thread->process;
@@ -368,16 +330,10 @@
         process->handles = copy_handle_table( process, parent );
     else
         process->handles = alloc_handle_table( process, 0 );
-    if (!process->handles) return NULL;
+    if (!process->handles) return 0;
 
     /* retrieve the main exe file */
-    reply->exe_file = 0;
-    if (info && info->exe_file)
-    {
-        process->exe.file = (struct file *)grab_object( info->exe_file );
-        if (!(reply->exe_file = alloc_handle( process, process->exe.file, GENERIC_READ, 0 )))
-            return NULL;
-    }
+    if (info && info->exe_file) process->exe.file = (struct file *)grab_object( info->exe_file );
 
     /* connect to the window station and desktop */
     connect_process_winstation( process, NULL, 0 );
@@ -385,9 +341,15 @@
     current->desktop = process->desktop;
 
     /* set the process console */
-    if (!set_process_console( process, parent_thread, info, reply )) return NULL;
+    if (info && !(info->create_flags & (DETACHED_PROCESS | CREATE_NEW_CONSOLE)))
+    {
+        /* FIXME: some better error checking should be done...
+         * like if hConOut and hConIn are console handles, then they should be on the same
+         * physical console
+         */
+        inherit_console( parent_thread, process, info->inherit_all ? info->hstdin : 0 );
+    }
 
-    process->group_id = get_process_id( process );
     if (parent)
     {
         /* attach to the debugger if requested */
@@ -404,13 +366,12 @@
 
     if (info)
     {
-        reply->info_size = info->data_size;
         info->process = (struct process *)grab_object( process );
         info->thread  = (struct thread *)grab_object( current );
+        process->startup_info = (struct startup_info *)grab_object( info );
+        return info->data_size;
     }
-    reply->create_flags = process->create_flags;
-    reply->server_start = server_start_ticks;
-    return info ? (struct startup_info *)grab_object( info ) : NULL;
+    return 0;
 }
 
 /* destroy a process when its refcount is 0 */
@@ -965,18 +926,43 @@
 /* Retrieve the new process startup info */
 DECL_HANDLER(get_startup_info)
 {
-    struct startup_info *info;
+    struct process *process = current->process;
+    struct startup_info *info = process->startup_info;
+    size_t size;
 
-    if ((info = current->process->startup_info))
+    if (!info) return;
+
+    reply->create_flags = info->create_flags;
+
+    if (info->exe_file &&
+        !(reply->exe_file = alloc_handle( process, info->exe_file, GENERIC_READ, 0 ))) return;
+
+    if (!info->inherit_all && !(info->create_flags & CREATE_NEW_CONSOLE))
     {
-        size_t size = info->data_size;
-        if (size > get_reply_max_size()) size = get_reply_max_size();
-
-        /* we return the data directly without making a copy so this can only be called once */
-        set_reply_data_ptr( info->data, size );
-        info->data = NULL;
-        info->data_size = 0;
+        struct process *parent_process = info->owner->process;
+        reply->hstdin  = duplicate_handle( parent_process, info->hstdin, process,
+                                           0, TRUE, DUPLICATE_SAME_ACCESS );
+        reply->hstdout = duplicate_handle( parent_process, info->hstdout, process,
+                                           0, TRUE, DUPLICATE_SAME_ACCESS );
+        reply->hstderr = duplicate_handle( parent_process, info->hstderr, process,
+                                           0, TRUE, DUPLICATE_SAME_ACCESS );
+        /* some handles above may have been invalid; this is not an error */
+        if (get_error() == STATUS_INVALID_HANDLE ||
+            get_error() == STATUS_OBJECT_TYPE_MISMATCH) clear_error();
     }
+    else
+    {
+        reply->hstdin  = info->hstdin;
+        reply->hstdout = info->hstdout;
+        reply->hstderr = info->hstderr;
+    }
+
+    /* we return the data directly without making a copy so this can only be called once */
+    size = info->data_size;
+    if (size > get_reply_max_size()) size = get_reply_max_size();
+    set_reply_data_ptr( info->data, size );
+    info->data = NULL;
+    info->data_size = 0;
 }
 
 
@@ -1003,10 +989,10 @@
         fatal_protocol_error( current, "init_process: bad ldt_copy address\n" );
         return;
     }
-    reply->info_size = 0;
     current->process->peb = req->peb;
     current->process->ldt_copy = req->ldt_copy;
-    current->process->startup_info = init_process( reply );
+    reply->server_start = server_start_ticks;
+    reply->info_size = init_process();
 }
 
 /* signal the end of the process initialization */
diff --git a/server/process.h b/server/process.h
index 3949bc4..359b33a 100644
--- a/server/process.h
+++ b/server/process.h
@@ -64,7 +64,7 @@
     int                  priority;        /* priority class */
     int                  affinity;        /* process affinity mask */
     int                  suspend;         /* global process suspend count */
-    int                  create_flags;    /* process creation flags */
+    unsigned int         create_flags;    /* process creation flags */
     struct list          locks;           /* list of file locks owned by the process */
     struct list          classes;         /* window classes owned by the process */
     struct console_input*console;         /* console input */
diff --git a/server/protocol.def b/server/protocol.def
index a2e558f..4d6ed4d 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -199,7 +199,7 @@
 /* Create a new process from the context of the parent */
 @REQ(new_process)
     int          inherit_all;  /* inherit all handles from parent */
-    int          create_flags; /* creation flags */
+    unsigned int create_flags; /* creation flags */
     int          unix_pid;     /* Unix pid of new process */
     obj_handle_t exe_file;     /* file handle for main exe */
     obj_handle_t hstdin;       /* handle for stdin */
@@ -248,19 +248,19 @@
     void*        peb;          /* addr of PEB */
     void*        ldt_copy;     /* addr of LDT copy */
 @REPLY
-    int          create_flags; /* creation flags */
     unsigned int server_start; /* server start time (GetTickCount) */
     size_t       info_size;    /* total size of startup info */
-    obj_handle_t exe_file;     /* file handle for main exe */
-    obj_handle_t hstdin;       /* handle for stdin */
-    obj_handle_t hstdout;      /* handle for stdout */
-    obj_handle_t hstderr;      /* handle for stderr */
 @END
 
 
 /* Retrieve the new process startup info */
 @REQ(get_startup_info)
 @REPLY
+    unsigned int create_flags; /* creation flags */
+    obj_handle_t exe_file;     /* file handle for main exe */
+    obj_handle_t hstdin;       /* handle for stdin */
+    obj_handle_t hstdout;      /* handle for stdout */
+    obj_handle_t hstderr;      /* handle for stderr */
     VARARG(info,startup_info); /* startup information */
     VARARG(env,unicode_str);   /* environment */
 @END
diff --git a/server/trace.c b/server/trace.c
index b284433..c9edc51 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -559,7 +559,7 @@
 static void dump_new_process_request( const struct new_process_request *req )
 {
     fprintf( stderr, " inherit_all=%d,", req->inherit_all );
-    fprintf( stderr, " create_flags=%d,", req->create_flags );
+    fprintf( stderr, " create_flags=%08x,", req->create_flags );
     fprintf( stderr, " unix_pid=%d,", req->unix_pid );
     fprintf( stderr, " exe_file=%p,", req->exe_file );
     fprintf( stderr, " hstdin=%p,", req->hstdin );
@@ -619,13 +619,8 @@
 
 static void dump_init_process_reply( const struct init_process_reply *req )
 {
-    fprintf( stderr, " create_flags=%d,", req->create_flags );
     fprintf( stderr, " server_start=%08x,", req->server_start );
-    fprintf( stderr, " info_size=%d,", req->info_size );
-    fprintf( stderr, " exe_file=%p,", req->exe_file );
-    fprintf( stderr, " hstdin=%p,", req->hstdin );
-    fprintf( stderr, " hstdout=%p,", req->hstdout );
-    fprintf( stderr, " hstderr=%p", req->hstderr );
+    fprintf( stderr, " info_size=%d", req->info_size );
 }
 
 static void dump_get_startup_info_request( const struct get_startup_info_request *req )
@@ -634,6 +629,11 @@
 
 static void dump_get_startup_info_reply( const struct get_startup_info_reply *req )
 {
+    fprintf( stderr, " create_flags=%08x,", req->create_flags );
+    fprintf( stderr, " exe_file=%p,", req->exe_file );
+    fprintf( stderr, " hstdin=%p,", req->hstdin );
+    fprintf( stderr, " hstdout=%p,", req->hstdout );
+    fprintf( stderr, " hstderr=%p,", req->hstderr );
     fprintf( stderr, " info=" );
     dump_varargs_startup_info( cur_size );
     fputc( ',', stderr );