Commit ee6369a6 authored by simonmar's avatar simonmar
Browse files

[project @ 1999-11-09 10:46:25 by simonmar]

Reset standard file descriptors to blocking mode on exit.
parent b38a2d75
# $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
......@@ -16,7 +16,7 @@ C_SRCS= $(wildcard *.c)
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
*/
......@@ -17,6 +17,7 @@ implementation in one or two places.)
*/
#include "Rts.h"
#include "RtsUtils.h"
#include "stgio.h"
#ifdef HAVE_FCNTL_H
......@@ -32,13 +33,8 @@ StgInt len;
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
*
......@@ -192,6 +192,11 @@ shutdownHaskell(void)
/* 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
*
......@@ -19,6 +19,10 @@
#include <time.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#include <stdarg.h>
/* variable-argument error function. */
......@@ -183,6 +187,26 @@ time_str(void)
}
#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
*
......@@ -22,6 +22,8 @@ extern void raiseError( StgStablePtr handler );
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*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment