kernel: Better support for detached processes.
Call setsid() in the new process to create a new Unix process group
when CREATE_NEW_PROCESS_GROUP, CREATE_NEW_CONSOLE, or DETACHED_PROCESS
are specified.
diff --git a/dlls/kernel/process.c b/dlls/kernel/process.c
index 62b6669..d1ff341 100644
--- a/dlls/kernel/process.c
+++ b/dlls/kernel/process.c
@@ -1116,7 +1116,7 @@
* Fork and exec a new Unix binary, checking for errors.
*/
static int fork_and_exec( const char *filename, const WCHAR *cmdline,
- const WCHAR *env, const char *newdir )
+ const WCHAR *env, const char *newdir, DWORD flags )
{
int fd[2];
int pid, err;
@@ -1135,6 +1135,8 @@
char **envp = build_envp( env );
close( fd[0] );
+ if (flags & (CREATE_NEW_PROCESS_GROUP | CREATE_NEW_CONSOLE | DETACHED_PROCESS)) setsid();
+
/* Reset signals that we previously set to SIG_IGN */
signal( SIGPIPE, SIG_DFL );
signal( SIGCHLD, SIG_DFL );
@@ -1302,6 +1304,8 @@
if (read( startfd[0], &dummy, 1 ) != 1) _exit(1);
close( startfd[0] );
+ if (flags & (CREATE_NEW_PROCESS_GROUP | CREATE_NEW_CONSOLE | DETACHED_PROCESS)) setsid();
+
/* Reset signals that we previously set to SIG_IGN */
signal( SIGPIPE, SIG_DFL );
signal( SIGCHLD, SIG_DFL );
@@ -1743,7 +1747,7 @@
if ((unix_name = wine_get_unix_file_name( name )))
{
- retv = (fork_and_exec( unix_name, tidy_cmdline, envW, unixdir ) != -1);
+ retv = (fork_and_exec( unix_name, tidy_cmdline, envW, unixdir, flags ) != -1);
HeapFree( GetProcessHeap(), 0, unix_name );
}
}