Skip to content

Commit d99fc81

Browse files
committed
Restore standard streams on interrupt (WIP)
1 parent e6ce88e commit d99fc81

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/pl-trace.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,6 +1896,15 @@ goal above the local stack top pointer. To avoid problems we just
18961896
increment the top pointer to point above the furthest argument.
18971897
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
18981898

1899+
static void
1900+
restoreStandardStreams(void)
1901+
{ if ( PL_thread_self() == 1 && truePrologFlag(PLFLAG_EPILOG) )
1902+
{ restoreStandardStream(SNO_USER_ERROR);
1903+
restoreStandardStream(SNO_USER_OUTPUT);
1904+
}
1905+
}
1906+
1907+
18991908
static void
19001909
helpInterrupt(void)
19011910
{ GET_LD
@@ -1955,6 +1964,7 @@ interruptHandler(int sig)
19551964
safe = !LD->critical;
19561965
#endif /* no async signals; always safe */
19571966

1967+
restoreStandardStreams();
19581968
Sreset();
19591969
again:
19601970
if ( safe )

0 commit comments

Comments
 (0)