about summary refs log tree commit diff stats
path: root/src/LYMain.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/LYMain.c')
-rw-r--r--src/LYMain.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/LYMain.c b/src/LYMain.c
index a06c4bf3..11b2b916 100644
--- a/src/LYMain.c
+++ b/src/LYMain.c
@@ -810,6 +810,19 @@ PRIVATE BOOL GetStdin ARGS1(
     return FALSE;
 }
 
+#ifdef WIN32
+PRIVATE BOOL cleanup_win32(DWORD fdwCtrlType)
+{
+    switch (fdwCtrlType) {
+    case CTRL_CLOSE_EVENT:
+	cleanup_sig(-1);
+    	return TRUE;
+    default:
+	return FALSE;
+    }
+}
+#endif
+
 /*
  * Wow!  Someone wants to start up Lynx.
  */
@@ -1450,17 +1463,21 @@ PUBLIC int main ARGS2(
     }
 
 #undef TTY_DEVICE
+#undef NUL_DEVICE
 
 #ifdef VMS
 #define TTY_DEVICE "tt:"
+#define NUL_DEVICE "nl:"
 #endif
 
 #ifdef _WINDOWS
 #define TTY_DEVICE "con"
+#define NUL_DEVICE "nul"
 #endif
 
 #ifndef TTY_DEVICE
 #define TTY_DEVICE "/dev/tty"
+#define NUL_DEVICE "/dev/null"
 #endif
 
 #if defined (TTY_DEVICE) || defined(HAVE_TTYNAME)
@@ -1476,9 +1493,9 @@ PUBLIC int main ARGS2(
 	tty = ttyname(fileno(stderr));
 # endif
 	if (tty == NULL)
-	    tty = TTY_DEVICE;
+	    tty = isatty(fileno(stdin)) ? TTY_DEVICE : NUL_DEVICE;
 
-	CTRACE((tfp, "processing stdin startfile\n"));
+	CTRACE((tfp, "processing stdin startfile, tty=%s\n", tty));
 	if ((fp = LYOpenTemp (result, HTML_SUFFIX, "w")) != 0) {
 	    StrAllocCopy(startfile, result);
 	    while (GetStdin(&buf)) {
@@ -1489,8 +1506,7 @@ PUBLIC int main ARGS2(
 	    LYCloseTempFP(fp);
 	}
 	CTRACE((tfp, "...done stdin startfile\n"));
-	if ((freopen(tty, "r", stdin)) == 0
-	 || !isatty(fileno(stdin))) {
+	if ((freopen(tty, "r", stdin)) == 0) {
 	    CTRACE((tfp, "cannot open a terminal (%s)\n", tty));
 	    if (!dump_output_immediately) {
 		fprintf(stderr, "cannot open a terminal (%s)\n", tty);
@@ -1740,13 +1756,17 @@ PUBLIC int main ARGS2(
 #endif  /* __DJGPP__ */
 
     /* trap interrupts */
+#ifdef WIN32
+    SetConsoleCtrlHandler((PHANDLER_ROUTINE) cleanup_win32, TRUE);
+#endif
     if (!dump_output_immediately)
 #ifndef NOSIGHUP
 	(void) signal(SIGHUP, cleanup_sig);
 #endif /* NOSIGHUP */
+
     (void) signal(SIGTERM, cleanup_sig);
 #ifdef SIGWINCH
-	LYExtSignal(SIGWINCH, size_change);
+    LYExtSignal(SIGWINCH, size_change);
 #endif /* SIGWINCH */
 #ifndef VMS
     if (!TRACE && !dump_output_immediately && !stack_dump) {
le-island.net> 1998-11-10 19:47:00 -0500 committer Thomas E. Dickey <dickey@invisible-island.net> 1998-11-10 19:47:00 -0500 snapshot of project "lynx", label v2-8-2dev_2' href='/ingrix/lynx-snapshots/commit/WWW/Library/Implementation/HTDOS.c?id=d3f9d5478df478427c2aa5db4507ddd0a38f0eb6'>d3f9d547 ^
1d80538b ^
8bccca15 ^

e4409c40 ^
8bccca15 ^


e4409c40 ^
8bccca15 ^

e4409c40 ^
8bccca15 ^



e4409c40 ^
8bccca15 ^
1d80538b ^


349da2fb ^

1d80538b ^
349da2fb ^
1d80538b ^

349da2fb ^
1d80538b ^
d3f9d547 ^
349da2fb ^
8bccca15 ^


e4409c40 ^
8bccca15 ^
e4409c40 ^
8bccca15 ^


e4409c40 ^
8bccca15 ^
e4409c40 ^
8bccca15 ^
18024037 ^
8bccca15 ^


e4409c40 ^
8bccca15 ^

e4409c40 ^
8bccca15 ^







e4409c40 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89