diff --git a/src/actions.c b/src/actions.c index 646aae6a..2d77785c 100644 --- a/src/actions.c +++ b/src/actions.c @@ -284,11 +284,15 @@ void new_window(const char* cell, int symbol) ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); ZeroMemory(&pi, sizeof(pi)); - if (!cell || !cell[0]) { - if (!symbol) - my_snprintf(cmd_line, S(cmd_line), "%s -b -s", xschem_executable); + /* "detach" (-b) is not processed for Windows, so + use DETACHED_PROCESS in CreateProcessA to not create + a TCL shell + */ + if (!cell || !cell[0]) { + if (!symbol) + my_snprintf(cmd_line, S(cmd_line), "%s -b -s --tcl \"set XSCHEM_START_WINDOW {}\"", xschem_executable); else - my_snprintf(cmd_line, S(cmd_line), "%s -b -y", xschem_executable); + my_snprintf(cmd_line, S(cmd_line), "%s -b -y --tcl \"set XSCHEM_START_WINDOW {}\"", xschem_executable); } else if (!symbol) { my_snprintf(cmd_line, S(cmd_line), "%s -b -s \"%s\"", xschem_executable, cell); @@ -304,7 +308,7 @@ void new_window(const char* cell, int symbol) NULL, /* Process handle not inheritable */ NULL, /* Thread handle not inheritable */ FALSE, /* Set handle inheritance to FALSE */ - CREATE_NEW_CONSOLE, /* Opens file in a separate console */ + DETACHED_PROCESS, /* Opens file in a separate console */ NULL, /* Use parent's environment block */ NULL, /* Use parent's starting directory */ &si, /* Pointer to STARTUPINFO structure */ diff --git a/src/main.c b/src/main.c index 85fc1052..edb5cabf 100644 --- a/src/main.c +++ b/src/main.c @@ -86,8 +86,9 @@ int main(int argc, char **argv) fprintf(errfp, "main(): no DISPLAY set, assuming no X available\n"); /* detach from console (fork a child and close std file descriptors) */ -#ifdef __unix__ + if(detach) { +#ifdef __unix__ pid_t pid = fork(); if(pid < 0) { fprintf(errfp, "main(): fork() failed\n"); @@ -106,8 +107,8 @@ int main(int argc, char **argv) /* terminate parent */ exit(0); } - } #endif + } if(has_x) Tk_Main(1, argv, Tcl_AppInit); else Tcl_Main(1, argv, Tcl_AppInit); diff --git a/src/xinit.c b/src/xinit.c index 6a344516..c9775a8f 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -1831,6 +1831,9 @@ int Tcl_AppInit(Tcl_Interp *inter) char * tmp; char filename[PATH_MAX]; tmp = (char *) tclgetvar("XSCHEM_START_WINDOW"); +#ifndef __unix__ + change_to_unix_fn(tmp); +#endif dbg(1, "Tcl_AppInit(): tmp=%s\n", tmp? tmp: "NULL"); my_strncpy(filename, abs_sym_path(tmp, ""), S(filename)); /* if do_netlist=1 call load_schematic with 'reset_undo=0' avoiding call @@ -1924,11 +1927,7 @@ int Tcl_AppInit(Tcl_Interp *inter) /* */ - if( -#ifdef __unix__ - !detach && -#endif - !no_readline) { + if(!detach && !no_readline) { tcleval( "if {![catch {package require tclreadline}]} " "{::tclreadline::readline builtincompleter 0;" /* "::tclreadline::readline customcompleter completer;" */