/* -----------------------------------------------------------------------------
- * $Id: stgio.h,v 1.24 2000/11/07 10:42:57 simonmar Exp $
+ * $Id: stgio.h,v 1.25 2001/01/16 14:06:14 simonmar Exp $
*
* (c) The GRASP/AQUA Project, Glasgow University, 1994-1999
*
/* closeFile.c */
StgInt closeFile (StgForeignPtr,StgInt);
-/* createDirectory.c */
-StgInt createDirectory (StgByteArray);
-
-/* directoryAux.c */
-StgAddr openDir__ (StgByteArray);
-StgAddr readDir__ (StgAddr);
-StgAddr get_dirent_d_name (StgAddr);
-StgWord get_stat_st_mode (StgAddr);
-StgInt64 get_stat_st_mtime(StgAddr);
-void set_stat_st_mtime(StgByteArray, StgByteArray);
-StgInt sizeof_stat (void);
-StgInt prim_stat (StgAddr,StgAddr);
-StgWord const_S_IRUSR (void);
-StgWord const_S_IWUSR (void);
-StgWord const_S_IXUSR (void);
-StgWord const_R_OK (void);
-StgWord const_W_OK (void);
-StgWord const_X_OK (void);
-StgWord const_F_OK (void);
-StgInt prim_S_ISDIR (StgWord);
-StgInt prim_S_ISREG (StgWord);
-
/* echoAux.c */
StgInt setTerminalEcho (StgForeignPtr, StgInt);
StgInt getTerminalEcho (StgForeignPtr);
/* getBufferMode.c */
StgInt getBufferMode (StgForeignPtr);
-/* getClockTime.c */
-StgInt getClockTime (StgByteArray, StgByteArray);
-StgInt prim_getClockTime(StgByteArray, StgByteArray);
-
/* getCPUTime.c */
StgInt getCPUTime (StgByteArray);
StgInt clockTicks(void);
-/* getCurrentDirectory.c */
-StgAddr getCurrentDirectory(void);
-
-/* getDirectoryContents.c */
-StgAddr getDirectoryContents (StgByteArray);
-
/* getLock.c */
int lockFile (int, int, int);
int unlockFile (int);
StgInt readLine (StgForeignPtr);
StgInt readChar (StgForeignPtr);
-/* removeDirectory.c */
-StgInt removeDirectory (StgByteArray);
-
-/* removeFile.c */
-StgInt removeFile (StgByteArray);
-
-/* renameDirectory.c */
-StgInt renameDirectory (StgByteArray, StgByteArray);
-
-/* renameFile.c */
-StgInt renameFile (StgByteArray, StgByteArray);
-
/* seekFile.c */
StgInt seekFile (StgForeignPtr, StgInt, StgInt, StgByteArray);
StgInt seekFile_int64 (StgForeignPtr, StgInt, StgInt64);
/* system.c */
StgInt systemCmd (StgByteArray);
-/* timezone.c */
-StgInt get_tm_sec ( StgAddr );
-StgInt get_tm_min ( StgAddr );
-StgInt get_tm_hour ( StgAddr );
-StgInt get_tm_mday ( StgAddr );
-StgInt get_tm_mon ( StgAddr );
-StgInt get_tm_year ( StgAddr );
-StgInt get_tm_wday ( StgAddr );
-StgInt get_tm_yday ( StgAddr );
-StgInt get_tm_isdst ( StgAddr );
-StgAddr prim_ZONE ( StgAddr );
-StgInt prim_GMTOFF ( StgAddr );
-void prim_SETZONE ( StgAddr, StgAddr );
-StgInt sizeof_word ( void );
-StgInt sizeof_struct_tm ( void );
-StgInt sizeof_time_t ( void );
-char* get_ZONE ( StgAddr );
-
-/* toLocalTime.c */
-StgInt toLocalTime (StgInt, StgByteArray, StgByteArray);
-StgInt prim_toLocalTime ( StgInt64,StgByteArray );
-
-/* toUTCTime.c */
-StgInt toUTCTime (StgInt, StgByteArray, StgByteArray);
-StgInt prim_toUTCTime ( StgInt64,StgByteArray );
-
-/* toClockSec.c */
-StgInt toClockSec (StgInt, StgInt, StgInt, StgInt, StgInt, StgInt, StgInt, StgInt, StgByteArray);
-
/* writeError.c */
StgAddr addrOf_ErrorHdrHook(void);
void writeErrString__ (StgAddr, StgByteArray, StgInt);
StgInt writeBuffer (StgForeignPtr, StgInt);
StgInt write_ (StgForeignPtr ptr, StgAddr buf, StgInt len);
+/* tcSetAttr.c */
+#ifdef HAVE_TERMIOS_H
+#include <termios.h>
+#endif
+int tcSetAttr (int fd, int options, const struct termios *tp);
+
#endif /* ! STGIO_H */
--- /dev/null
+/*
+ * (c) The GHC Team 2001
+ *
+ * $Id: tcSetAttr.c,v 1.1 2001/01/16 14:06:14 simonmar Exp $
+ *
+ * A wrapper around tcsetattr() which works for a background process.
+ */
+
+#include "Rts.h"
+#include "stgio.h"
+
+#ifdef HAVE_SIGNAL_H
+#include <signal.h>
+#endif
+
+#ifdef HAVE_TERMIOS_H
+#include <termios.h>
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+/* tcsetattr() when invoked by a background process causes the process
+ * to be sent SIGTTOU regardless of whether the process has TOSTOP set
+ * in its terminal flags (try it...). This function provides a
+ * wrapper which temporarily blocks SIGTTOU around the call, making it
+ * transparent. */
+int
+tcSetAttr( int fd, int options, const struct termios *tp )
+{
+ int res;
+ sigset_t block_ttou, old_sigset;
+
+ sigemptyset (&block_ttou);
+ sigaddset (&block_ttou, SIGTTOU);
+ sigprocmask(SIG_BLOCK, &block_ttou, &old_sigset);
+ res = tcsetattr(fd, options, tp);
+ sigprocmask(SIG_SETMASK, &old_sigset, NULL);
+
+ return res;
+}