From: sof Date: Thu, 5 May 2005 00:58:38 +0000 (+0000) Subject: [project @ 2005-05-05 00:58:38 by sof] X-Git-Tag: Initial_conversion_from_CVS_complete~606 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=4d57994585c858a7be242c8db23a3e40834dfc72;p=ghc-hetmet.git [project @ 2005-05-05 00:58:38 by sof] [mingw only] Provide (unsatisfying) workaround for pesky Ctrl-C issue, whereby a cygwin-based bash will terminate the 'ghci.exe' wrapper without the wrapper process getting a chance to respond (and shut down its child, if nothing else.) The result instead being that the child (ghc.exe) ends up lingering in the background. To steer users away from such badness, the wrapper checks to see whether it is running in a *nix-like shell, and if it is, issue a warning that it would be better to invoke GHCi using the 'ghcii.sh' shell script instead. Merge to STABLE. --- diff --git a/ghc/driver/ghci/Makefile b/ghc/driver/ghci/Makefile index aeb229c..9392249 100644 --- a/ghc/driver/ghci/Makefile +++ b/ghc/driver/ghci/Makefile @@ -1,5 +1,5 @@ #----------------------------------------------------------------------------- -# $Id: Makefile,v 1.10 2002/01/10 10:33:48 sof Exp $ +# $Id: Makefile,v 1.11 2005/05/05 00:58:38 sof Exp $ # TOP=../.. @@ -40,6 +40,7 @@ SCRIPT_SUBST_VARS = GHCBIN TOPDIROPT ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32" INSTALL_SCRIPTS += $(SCRIPT_PROG) else +INSTALL_SCRIPTS += ghcii.sh INSTALL_PROGS += $(C_PROG) endif TOPDIROPT = -B$(GHCLIB) diff --git a/ghc/driver/ghci/ghci.c b/ghc/driver/ghci/ghci.c index a41723a..f21a12a 100644 --- a/ghc/driver/ghci/ghci.c +++ b/ghc/driver/ghci/ghci.c @@ -1,6 +1,6 @@ /* * - * $Id: ghci.c,v 1.9 2005/04/22 17:15:51 sof Exp $ + * $Id: ghci.c,v 1.10 2005/05/05 00:58:38 sof Exp $ * * ghci wrapper for Win32 only * @@ -74,6 +74,12 @@ main(int argc, char** argv) ZeroMemory(&si, sizeof(STARTUPINFO)); si.cb = sizeof(STARTUPINFO); + if ( getenv("_") ) { + printf("WARNING: GHCi invoked via 'ghci.exe' in *nix-like shells (cygwin-bash, in particular)\n"); + printf(" doesn't handle Ctrl-C well; use the 'ghcii.sh' shell wrapper instead\n"); + fflush(stdout); + } + /* Locate the binary we want to start up */ if ( !SearchPath(NULL, BINARY_NAME, @@ -81,7 +87,7 @@ main(int argc, char** argv) dwSize, (char*)binPath, &szEnd) ) { - errmsg("Unable to locate ghc.exe"); + errmsg1("%s: Unable to locate ghc.exe", argv[0]); return 1; } @@ -89,7 +95,7 @@ main(int argc, char** argv) /* Turn the path into short form - LFN form causes problems when passed in argv[0]. */ if ( !(GetShortPathName(binPath, binPathShort, dwSize)) ) { - errmsg("Unable to locate ghc.exe"); + errmsg1("%s: Unable to locate ghc.exe", argv[0]); return 1; } @@ -101,7 +107,7 @@ main(int argc, char** argv) } new_cmdline = (char*)malloc(sizeof(char) * (cmdline_len + 1)); if (!new_cmdline) { - errmsg("failed to start up ghc.exe; insufficient memory"); + errmsg1("%s: failed to start up ghc.exe; insufficient memory", argv[0]); return 1; } diff --git a/ghc/driver/ghci/ghcii.sh b/ghc/driver/ghci/ghcii.sh new file mode 100644 index 0000000..70d9898 --- /dev/null +++ b/ghc/driver/ghci/ghcii.sh @@ -0,0 +1,3 @@ +#!/bin/sh +# Mini-driver for GHCi +exec $0/../ghc --interactive ${1+"$@"}