+ _nc_globals.init_screen = TRUE;
+
+ if ((name = getenv("TERM")) == 0
+ || *name == '\0')
+ name = "unknown";
+#ifdef __CYGWIN__
+ /*
+ * 2002/9/21
+ * Work around a bug in Cygwin. Full-screen subprocesses run from
+ * bash, in turn spawned from another full-screen process, will dump
+ * core when attempting to write to stdout. Opening /dev/tty
+ * explicitly seems to fix the problem.
+ */
+ if (NC_ISATTY(fileno(stdout))) {
+ FILE *fp = fopen("/dev/tty", "w");
+ if (fp != 0 && NC_ISATTY(fileno(fp))) {
+ fclose(stdout);
+ dup2(fileno(fp), STDOUT_FILENO);
+ stdout = fdopen(STDOUT_FILENO, "w");
+ }
+ }
+#endif
+ if (newterm(name, stdout, stdin) == 0) {
+ fprintf(stderr, "Error opening terminal: %s.\n", name);
+ exit(EXIT_FAILURE);