From 6c2d8204302efc776a7a04c49a409aabbf257d5b Mon Sep 17 00:00:00 2001 From: h_vogt Date: Tue, 26 Mar 2013 20:35:41 +0100 Subject: [PATCH] sharedspice.c: command bg_pstop to stop printsend thread before unloading ngspice library --- src/sharedspice.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/sharedspice.c b/src/sharedspice.c index 80911efd4..941db8386 100644 --- a/src/sharedspice.c +++ b/src/sharedspice.c @@ -244,6 +244,8 @@ mutexType fputsMutex; static bool is_initialized = FALSE; static char* no_init = "Error: ngspice is not initialized!\n Run ngSpice_Init first"; +static bool printstopp = FALSE; + /*helper function*//* static struct plot * get_plot(int plot) @@ -383,10 +385,22 @@ runc(char* command) bool fl_bg = FALSE; command_id = threadid_self(); /* run task in background if command is preceeded by "bg_" */ - if (!cieq("bg_halt", command) && (ciprefix("bg_", command))) { + if (!cieq("bg_halt", command) && !cieq("bg_pstop", command) &&(ciprefix("bg_", command))) { strncpy(buf, command+3, 1024); fl_bg = TRUE; } +#ifndef low_latency + /* stop the printf thread 'printsend()' */ + else if (cieq("bg_pstop", command)) { + printstopp = TRUE; +#if defined(__MINGW32__) || defined(_MSC_VER) + Sleep(100); // va: windows native +#else + usleep(10000); +#endif + return 2; + } +#endif else strncpy(buf, command, 1024); #else @@ -1070,7 +1084,7 @@ sh_fputs(const char *input, FILE* outf) again fcn outstoraghe(), top entry is deleted and string is sent to caller in an endless loop by fcn printsend() */ static wordlist *wlstart = NULL, *wlend = NULL; -static bool printstopp = FALSE; +//static bool printstopp = FALSE; int