Reset standard file descriptors to blocking mode on exit.
-# $Id: Makefile,v 1.7 1999/10/29 13:52:30 sof Exp $
+# $Id: Makefile,v 1.8 1999/11/09 10:46:27 simonmar Exp $
TOP = ../../..
include $(TOP)/mk/boilerplate.mk
C_OBJS = $(C_SRCS:.c=.$(way_)o)
LIBOBJS = $(C_OBJS)
-SRC_CC_OPTS += -O -I$(GHC_INCLUDE_DIR) $(GhcLibCcOpts)
+SRC_CC_OPTS += -O -I$(GHC_INCLUDE_DIR) -I$(GHC_RUNTIME_DIR) $(GhcLibCcOpts)
ifneq "$(way)" "dll"
SRC_CC_OPTS += -static
/*
* (c) The GRASP/AQUA Project, Glasgow University, 1998
*
- * $Id: writeError.c,v 1.3 1999/11/05 15:22:59 simonmar Exp $
+ * $Id: writeError.c,v 1.4 1999/11/09 10:46:27 simonmar Exp $
*
* hPutStr Runtime Support
*/
*/
#include "Rts.h"
+#include "RtsUtils.h"
#include "stgio.h"
#ifdef HAVE_FCNTL_H
int count = 0;
char* p = (char*)msg;
char nl = '\n';
- long fd_flags;
-#if !defined(_WIN32) || defined(__CYGWIN__) || defined(__CYGWIN32__)
- /* clear the non-blocking flag on this file descriptor */
- fd_flags = fcntl(2, F_GETFL);
- fcntl(2, F_SETFL, fd_flags & ~O_NONBLOCK);
-#endif
+ resetNonBlockingFd(2);
/* Print error msg header */
if (msg_hdr) {
/* -----------------------------------------------------------------------------
- * $Id: RtsStartup.c,v 1.23 1999/11/02 17:19:15 simonmar Exp $
+ * $Id: RtsStartup.c,v 1.24 1999/11/09 10:46:26 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
/* stop the ticker */
initialize_virtual_timer(0);
+ /* reset the standard file descriptors to blocking mode */
+ resetNonBlockingFd(0);
+ resetNonBlockingFd(1);
+ resetNonBlockingFd(2);
+
/* stop timing the shutdown, we're about to print stats */
stat_endExit();
/* -----------------------------------------------------------------------------
- * $Id: RtsUtils.c,v 1.9 1999/08/25 16:11:51 simonmar Exp $
+ * $Id: RtsUtils.c,v 1.10 1999/11/09 10:46:26 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
#include <time.h>
#endif
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+
#include <stdarg.h>
/* variable-argument error function. */
#endif
/* -----------------------------------------------------------------------------
+ * Reset a file handle to blocking mode. We do this for the standard
+ * file descriptors before exiting, because the shell doesn't always
+ * clean up for us.
+ * -------------------------------------------------------------------------- */
+
+void
+resetNonBlockingFd(int fd)
+{
+ long fd_flags;
+
+#if !defined(_WIN32) || defined(__CYGWIN__) || defined(__CYGWIN32__)
+ /* clear the non-blocking flag on this file descriptor */
+ fd_flags = fcntl(fd, F_GETFL);
+ if (fd_flags & O_NONBLOCK) {
+ fcntl(fd, F_SETFL, fd_flags & ~O_NONBLOCK);
+ }
+#endif
+}
+
+/* -----------------------------------------------------------------------------
Print large numbers, with punctuation.
-------------------------------------------------------------------------- */
/* -----------------------------------------------------------------------------
- * $Id: RtsUtils.h,v 1.4 1999/03/17 13:19:23 simonm Exp $
+ * $Id: RtsUtils.h,v 1.5 1999/11/09 10:46:25 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
extern void stackOverflow(void);
extern void heapOverflow(void);
+void resetNonBlockingFd(int fd);
+
extern nat stg_strlen(char *str);
/*Defined in Main.c, but made visible here*/