changed code to prevent buffered output from span across the end of hawk_rtx_execXXX()
This commit is contained in:
parent
e54537886c
commit
cd7873e19a
@ -1221,11 +1221,6 @@ static HAWK_INLINE int execute_hawk (int argc, hawk_bch_t* argv[])
|
||||
hawk_rtx_execwithbcstrarr(rtx, (const hawk_bch_t**)arg.icf.ptr, arg.icf.size);
|
||||
#endif
|
||||
|
||||
/* clear unflushed io data - this is also done by hawk_rtx_close().
|
||||
* but i restore the SIGPIPE handler to the default in unset_intr_run().
|
||||
* any output after this restoration may cause the program to terminate for unhandled SIGPIPE */
|
||||
hawk_rtx_cleario (rtx);
|
||||
|
||||
unset_intr_run ();
|
||||
|
||||
if (retv)
|
||||
|
@ -1794,8 +1794,18 @@ int Hawk::call (const hawk_uch_t* name, Value* ret, const Value* args, hawk_oow_
|
||||
|
||||
int Hawk::exec (Value* ret, const Value* args, hawk_oow_t nargs)
|
||||
{
|
||||
return (this->runctx.rtx->hawk->parse.pragma.entry[0] != '\0')?
|
||||
int n = (this->runctx.rtx->hawk->parse.pragma.entry[0] != '\0')?
|
||||
this->call(this->runctx.rtx->hawk->parse.pragma.entry, ret, args, nargs): this->loop(ret);
|
||||
|
||||
hawk_rtx_cleario (this->runctx.rtx);
|
||||
|
||||
#if defined(HAWK_ENABLE_GC)
|
||||
/* i assume this function is a usual hawk program starter.
|
||||
* call garbage collection after a whole program finishes */
|
||||
hawk_rtx_gc (this->runctx.rtx, HAWK_RTX_GC_GEN_FULL);
|
||||
#endif
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
void Hawk::halt ()
|
||||
|
@ -1682,6 +1682,8 @@ hawk_val_t* hawk_rtx_execwithucstrarr (hawk_rtx_t* rtx, const hawk_uch_t* args[]
|
||||
hawk_rtx_callwithooucstrarr(rtx, rtx->hawk->parse.pragma.entry, args, nargs):
|
||||
hawk_rtx_loop(rtx);
|
||||
|
||||
hawk_rtx_cleario (rtx);
|
||||
|
||||
#if defined(HAWK_ENABLE_GC)
|
||||
/* i assume this function is a usual hawk program starter.
|
||||
* call garbage collection after a whole program finishes */
|
||||
|
@ -239,6 +239,11 @@ static void stop_run (int sig)
|
||||
if (app_hawk) app_hawk->halt ();
|
||||
errno = e;
|
||||
}
|
||||
|
||||
static void do_nothing (int sig)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static void set_signal (void)
|
||||
@ -248,6 +253,7 @@ static void set_signal (void)
|
||||
#else
|
||||
/*setsignal (SIGINT, stop_run, 1); TO BE MORE COMPATIBLE WITH WIN32*/
|
||||
setsignal (SIGINT, stop_run, 0);
|
||||
setsignal (SIGPIPE, do_nothing, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -257,6 +263,7 @@ static void unset_signal (void)
|
||||
SetConsoleCtrlHandler (stop_run, FALSE);
|
||||
#else
|
||||
setsignal (SIGINT, SIG_DFL, 1);
|
||||
setsignal (SIGPIPE, SIG_DFL, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user