main.c do not spawn a child closing std file descriptors if -b option is given, just start xschem without interactive tcl shell, handle error condition in setup_tcp_gaw
This commit is contained in:
parent
e449543805
commit
de1db1e87a
|
|
@ -178,7 +178,7 @@ char initial_netlist_name[PATH_MAX]={0};
|
|||
char bus_char[3] = {0, 0, 0};
|
||||
int yyparse_error = 0;
|
||||
char *xschem_executable=NULL;
|
||||
Tcl_Interp *interp;
|
||||
Tcl_Interp *interp = NULL;
|
||||
double *character[256]; /* array or per-char coordinates of xschem internal vector font */
|
||||
int do_netlist=0; /* set by process_options if user wants netllist from cmdline */
|
||||
int do_simulation=0;
|
||||
|
|
|
|||
|
|
@ -271,7 +271,8 @@ void create_plot_cmd(void)
|
|||
}
|
||||
fprintf(fd, "*ngspice plot file\n.control\n");
|
||||
}
|
||||
if(viewer == GAW) tcleval("if { ![info exists gaw_fd] } { setup_tcp_gaw }\n");
|
||||
if(viewer == GAW) tcleval("setup_tcp_gaw");
|
||||
if(tclresult()[0] == '0') return;
|
||||
idx = 1;
|
||||
first = 1;
|
||||
for(i=0;i<HASHSIZE;i++) /* set ngspice colors */
|
||||
|
|
@ -915,7 +916,8 @@ static void send_net_to_gaw(int simtype, const char *node)
|
|||
sprintf(color_str, "%02x%02x%02x", xctx->xcolor_array[c].red>>8, xctx->xcolor_array[c].green>>8,
|
||||
xctx->xcolor_array[c].blue>>8);
|
||||
expanded_tok = expandlabel(tok, &tok_mult);
|
||||
tcleval("if { ![info exists gaw_fd] } { setup_tcp_gaw }\n");
|
||||
tcleval("setup_tcp_gaw");
|
||||
if(tclresult()[0] == '0') return;
|
||||
for(k=1; k<=tok_mult; k++) {
|
||||
my_strdup(246, &t, find_nth(expanded_tok, ',', k));
|
||||
my_strdup2(254, &p, xctx->sch_path[xctx->currsch]+1);
|
||||
|
|
@ -1018,7 +1020,8 @@ static void send_current_to_gaw(int simtype, const char *node)
|
|||
sprintf(color_str, "%02x%02x%02x", xctx->xcolor_array[c].red>>8, xctx->xcolor_array[c].green>>8,
|
||||
xctx->xcolor_array[c].blue>>8);
|
||||
expanded_tok = expandlabel(tok, &tok_mult);
|
||||
tcleval("if { ![info exists gaw_fd] } { setup_tcp_gaw }\n");
|
||||
tcleval("setup_tcp_gaw");
|
||||
if(tclresult()[0] == '0') return;
|
||||
for(k=1; k<=tok_mult; k++) {
|
||||
my_strdup(1179, &t, find_nth(expanded_tok, ',', k));
|
||||
my_strdup2(1180, &p, xctx->sch_path[xctx->currsch]+1);
|
||||
|
|
|
|||
18
src/main.c
18
src/main.c
|
|
@ -85,8 +85,9 @@ int main(int argc, char **argv)
|
|||
if(debug_var>=1 && !has_x)
|
||||
fprintf(errfp, "main(): no DISPLAY set, assuming no X available\n");
|
||||
|
||||
/* detach from console (fork a child and close std file descriptors) */
|
||||
|
||||
#if 0
|
||||
/* detach from console (fork a child and close std file descriptors) */
|
||||
if(detach) {
|
||||
#ifdef __unix__
|
||||
pid_t pid = fork();
|
||||
|
|
@ -109,9 +110,20 @@ int main(int argc, char **argv)
|
|||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
if(has_x) Tk_Main(1, argv, Tcl_AppInit);
|
||||
else Tcl_Main(1, argv, Tcl_AppInit);
|
||||
/* if detach is 1 no interactive command shell is created ...
|
||||
* using detach if no windowing exists (has_x == 0) is non sense so do nothing
|
||||
*/
|
||||
if(detach && has_x) {
|
||||
Tcl_FindExecutable(argv[0]); /* tcl stores executable name for its internal usage */
|
||||
interp = Tcl_CreateInterp(); /* create the tcl interpreter */
|
||||
Tcl_AppInit(interp); /* execute our init function */
|
||||
Tk_MainLoop(); /* ok, now all done go into the event loop */
|
||||
} else { /* ... else start tcl or tk main loop and enter interactive mode (tcl shell) */
|
||||
if(has_x) Tk_Main(1, argv, Tcl_AppInit);
|
||||
else Tcl_Main(1, argv, Tcl_AppInit);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -886,7 +886,7 @@ int ps_draw(int what)
|
|||
|
||||
if(what & 1) { /* prolog */
|
||||
if(!lastdir[0]) my_strncpy(lastdir, pwd_dir, S(lastdir));
|
||||
if(!xctx->plotfile[0]) {
|
||||
if(has_x && !xctx->plotfile[0]) {
|
||||
tclvareval("tk_getSaveFile -title {Select destination file} -initialfile {",
|
||||
get_cell(xctx->sch[xctx->currsch], 0) , ".pdf} -initialdir {", lastdir, "}", NULL);
|
||||
r = tclresult();
|
||||
|
|
|
|||
|
|
@ -563,7 +563,7 @@ void svg_draw(void)
|
|||
struct hilight_hashentry *entry;
|
||||
|
||||
if(!lastdir[0]) my_strncpy(lastdir, pwd_dir, S(lastdir));
|
||||
if(!xctx->plotfile[0]) {
|
||||
if(has_x && !xctx->plotfile[0]) {
|
||||
tclvareval("tk_getSaveFile -title {Select destination file} -initialfile {",
|
||||
get_cell(xctx->sch[xctx->currsch], 0) , ".svg} -initialdir {", lastdir, "}", NULL);
|
||||
r = tclresult();
|
||||
|
|
|
|||
|
|
@ -1288,7 +1288,7 @@ int Tcl_AppInit(Tcl_Interp *inter)
|
|||
|
||||
/* set error and exit handlers */
|
||||
XSetErrorHandler(err);
|
||||
interp=inter;
|
||||
if(!interp) interp=inter;
|
||||
Tcl_Init(interp);
|
||||
if(has_x) {
|
||||
Tk_Init(interp);
|
||||
|
|
|
|||
|
|
@ -987,6 +987,7 @@ proc gaw_echoline {} {
|
|||
proc setup_tcp_gaw {} {
|
||||
global gaw_fd gaw_tcp_address netlist_dir has_x
|
||||
|
||||
if { [info exists gaw_fd] } { return 1; }
|
||||
simuldir
|
||||
set s [file tail [file rootname [xschem get schname 0]]]
|
||||
|
||||
|
|
@ -1000,11 +1001,12 @@ proc setup_tcp_gaw {} {
|
|||
"If you recently closed gaw the port may be in a TIME_WAIT state for a minute or so ." \
|
||||
"Close gaw, Wait a minute or two, then send waves to gaw again."]
|
||||
}
|
||||
return
|
||||
return 0
|
||||
}
|
||||
chan configure $gaw_fd -blocking 1 -buffering line -encoding binary -translation binary
|
||||
fileevent $gaw_fd readable gaw_echoline
|
||||
puts $gaw_fd "table_set $s.raw"
|
||||
return 1
|
||||
}
|
||||
|
||||
proc gaw_cmd {cmd} {
|
||||
|
|
|
|||
Loading…
Reference in New Issue