/* -----------------------------------------------------------------------------
- * $Id: RtsStartup.c,v 1.76 2003/09/24 10:32:11 simonmar Exp $
+ * $Id: RtsStartup.c,v 1.80 2004/03/19 23:17:06 panne Exp $
*
* (c) The GHC Team, 1998-2002
*
// Count of how many outstanding hs_init()s there have been.
static int hs_init_count = 0;
-#if HAVE_TERMIOS_H
// Here we save the terminal settings on the standard file
// descriptors, if we need to change them (eg. to support NoBuffering
// input).
-struct termios *saved_termios[3] = {NULL,NULL,NULL};
-#endif
+static void *saved_termios[3] = {NULL,NULL,NULL};
+
+void*
+__hscore_get_saved_termios(int fd)
+{
+ return (0 <= fd && fd < (int)(sizeof(saved_termios) / sizeof(*saved_termios))) ?
+ saved_termios[fd] : NULL;
+}
+
+void
+__hscore_set_saved_termios(int fd, void* ts)
+{
+ if (0 <= fd && fd < (int)(sizeof(saved_termios) / sizeof(*saved_termios))) {
+ saved_termios[fd] = ts;
+ }
+}
/* -----------------------------------------------------------------------------
Starting up the RTS
#endif
#ifdef HAVE_LOCALE_H
- setlocale(LC_ALL,"");
+ setlocale(LC_CTYPE,"");
#endif
/* Record initialization times */
/* start timing the shutdown */
stat_startExit();
- /* stop all running tasks */
- exitScheduler();
-
#if !defined(GRAN)
/* Finalize any remaining weak pointers */
finalizeWeakPointersNow();
#endif
+ /* stop all running tasks */
+ exitScheduler();
+
#if defined(GRAN)
/* end_gr_simulation prints global stats if requested -- HWL */
if (!RtsFlags.GranFlags.GranSimStats.Suppressed)
sigaddset(&sigset, SIGTTOU);
sigprocmask(SIG_BLOCK, &sigset, &old_sigset);
for (fd = 0; fd <= 2; fd++) {
- if (saved_termios[fd] != NULL) {
- tcsetattr(fd,TCSANOW,saved_termios[fd]);
+ struct termios* ts = (struct termios*)__hscore_get_saved_termios(fd);
+ if (ts != NULL) {
+ tcsetattr(fd,TCSANOW,ts);
}
}
sigprocmask(SIG_SETMASK, &old_sigset, NULL);