make rl not deadlock under SIGINT
This commit is contained in:
parent
73541f506f
commit
b868d85ac8
@ -517,6 +517,7 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
|
||||
error_exit_yap (1);
|
||||
}
|
||||
case PURE_ABORT:
|
||||
nt[0] = MkAtomTerm(AtomDAbort);
|
||||
fun = FunctorVar;
|
||||
serious = TRUE;
|
||||
break;
|
||||
|
18
C/sysbits.c
18
C/sysbits.c
@ -1547,6 +1547,8 @@ InteractSIGINT(int ch) {
|
||||
switch (ch) {
|
||||
case 'a':
|
||||
/* abort computation */
|
||||
if (Yap_PrologMode &= InReadlineMode) {
|
||||
}
|
||||
if (Yap_PrologMode & (GCMode|ConsoleGetcMode|GrowStackMode|GrowHeapMode)) {
|
||||
Yap_PrologMode |= AbortMode;
|
||||
} else {
|
||||
@ -1650,33 +1652,19 @@ HandleSIGINT (int sig, siginfo_t *x, ucontext_t *y)
|
||||
HandleSIGINT (int sig)
|
||||
#endif
|
||||
{
|
||||
LOCK(SignalLock);
|
||||
my_signal(SIGINT, HandleSIGINT);
|
||||
/* do this before we act */
|
||||
#if HAVE_ISATTY
|
||||
if (!isatty(0) && !Yap_sockets_io) {
|
||||
UNLOCK(SignalLock);
|
||||
Yap_Error(INTERRUPT_ERROR,MkIntTerm(SIGINT),NULL);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (Yap_InterruptsDisabled) {
|
||||
UNLOCK(SignalLock);
|
||||
return;
|
||||
}
|
||||
if (Yap_PrologMode & (CritMode|ConsoleGetcMode)) {
|
||||
Yap_PrologMode |= InterruptMode;
|
||||
#if HAVE_LIBREADLINE && HAVE_READLINE_READLINE_H
|
||||
if (Yap_PrologMode & ConsoleGetcMode) {
|
||||
fprintf(stderr, "Action (h for help): ");
|
||||
rl_point = rl_end = 0;
|
||||
#if HAVE_RL_SET_PROMPT
|
||||
rl_set_prompt("Action (h for help): ");
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
UNLOCK(SignalLock);
|
||||
return;
|
||||
}
|
||||
#ifdef HAVE_SETBUF
|
||||
/* make sure we are not waiting for the end of line */
|
||||
@ -1684,11 +1672,9 @@ HandleSIGINT (int sig)
|
||||
#endif
|
||||
if (snoozing) {
|
||||
snoozing = FALSE;
|
||||
UNLOCK(SignalLock);
|
||||
return;
|
||||
}
|
||||
ProcessSIGINT();
|
||||
UNLOCK(SignalLock);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
3
H/Yap.h
3
H/Yap.h
@ -1184,7 +1184,8 @@ typedef enum
|
||||
UserCCallMode = 0x4000, /* In User C-call Code */
|
||||
MallocMode = 0x8000, /* Doing malloc, realloc, free */
|
||||
SystemMode = 0x10000, /* in system mode */
|
||||
AsyncIntMode = 0x20000 /* YAP has just been interrupted from the outside */
|
||||
AsyncIntMode = 0x20000, /* YAP has just been interrupted from the outside */
|
||||
InReadlineMode = 0x40000 /* YAP has just been interrupted from the outside */
|
||||
} prolog_exec_mode;
|
||||
|
||||
extern Int Yap_PrologMode;
|
||||
|
@ -825,7 +825,7 @@ clean: clean_docs
|
||||
@INSTALL_DLLS@ (cd packages/semweb; $(MAKE) clean)
|
||||
@INSTALL_DLLS@ (cd packages/sgml; $(MAKE) clean)
|
||||
@USE_MINISAT@ (cd packages/swi-minisat2; $(MAKE) clean)
|
||||
@USE_MINISAT@ (cd packages/packages/CLPBN/bp; $(MAKE) clean)
|
||||
@USE_MINISAT@ (cd packages/CLPBN/clpbn/bp; $(MAKE) clean)
|
||||
@INSTALL_DLLS@ (cd packages/tai; $(MAKE) clean)
|
||||
@INSTALL_DLLS@ (cd packages/zlib; $(MAKE) clean)
|
||||
@ENABLE_CPLINT@ (cd packages/cplint/approx/simplecuddLPADs; $(MAKE) clean)
|
||||
|
@ -232,6 +232,7 @@
|
||||
#undef HAVE_RL_CLEAR_PENDING_INPUT
|
||||
#undef HAVE_RL_COMPLETION_MATCHES
|
||||
#undef HAVE_RL_FILENAME_COMPLETION_FUNCTION
|
||||
#undef HAVE_RL_FREE_LINE_STATE
|
||||
#undef HAVE_RL_INSERT_CLOSE
|
||||
#undef HAVE_RL_SET_PROMPT
|
||||
#undef HAVE_SBRK
|
||||
|
5
configure
vendored
5
configure
vendored
@ -7988,6 +7988,11 @@ fi
|
||||
ac_fn_c_check_func "$LINENO" "rl_filename_completion_function " "ac_cv_func_rl_filename_completion_function_"
|
||||
if test "x$ac_cv_func_rl_filename_completion_function_" = x""yes; then :
|
||||
|
||||
fi
|
||||
|
||||
ac_fn_c_check_func "$LINENO" "rl_free_line_state " "ac_cv_func_rl_free_line_state_"
|
||||
if test "x$ac_cv_func_rl_free_line_state_" = x""yes; then :
|
||||
|
||||
fi
|
||||
|
||||
ac_fn_c_check_func "$LINENO" "rl_set_prompt " "ac_cv_func_rl_set_prompt_"
|
||||
|
@ -1383,6 +1383,7 @@ then
|
||||
AC_CHECK_FUNC( rl_completion_matches )
|
||||
AC_CHECK_FUNC( rl_insert_close )
|
||||
AC_CHECK_FUNC( rl_filename_completion_function )
|
||||
AC_CHECK_FUNC( rl_free_line_state )
|
||||
AC_CHECK_FUNC( rl_set_prompt )
|
||||
AC_CHECK_FUNC( rl_clear_pending_input )
|
||||
fi
|
||||
|
@ -482,8 +482,9 @@ Sread_readline(void *handle, char *buf, size_t size)
|
||||
rl_prep_terminal(FALSE);
|
||||
rl_readline_state = state;
|
||||
rl_done = 0;
|
||||
} else
|
||||
} else {
|
||||
line = pl_readline(prompt);
|
||||
}
|
||||
in_readline--;
|
||||
|
||||
if ( my_prompt )
|
||||
@ -513,6 +514,12 @@ Sread_readline(void *handle, char *buf, size_t size)
|
||||
PL_clock_wait_ticks(clock() - oldclock);
|
||||
#endif
|
||||
|
||||
#if __YAP_PROLOG__
|
||||
/* handle abort */
|
||||
if (Yap_REGS.P_ == FAILCODE) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ YAPLIBDIR=@libdir@/Yap
|
||||
#
|
||||
DEFS=@DEFS@ -D_YAP_NOT_INSTALLED_=1
|
||||
CC=@CC@
|
||||
CFLAGS= @SHLIB_CFLAGS@ $(YAP_EXTRAS) $(DEFS) -I$(srcdir) -I../.. -I$(srcdir)/../../include -I$(srcdir)/../PLStream
|
||||
CFLAGS= @SHLIB_CFLAGS@ $(YAP_EXTRAS) $(DEFS) -I$(srcdir) -I../.. -I$(srcdir)/../../include -I$(srcdir)/../PLStream -I$(srcdir)/../../H
|
||||
#
|
||||
#
|
||||
# You shouldn't need to change what follows.
|
||||
|
Reference in New Issue
Block a user