Overview
| Artifact ID: | b095f64ec876decd7dd014b8925ca15d99b6cc4a |
|---|---|
| Ticket: | 219355ffffffffffffffffffffffffffffffffff
fix proposal for TR#5312 (part 2) |
| User & Date: | nobody on 2000-10-26 05:11:16 |
Changes
- assignee changed to: "nobody"
- cmimetype changed to: "text/plain"
- comment changed to:
OriginalBugID: 5829 Bug Version: 8.4a1 SubmitDate: '2000-06-06' LastModified: '2000-09-01' Severity: LOW Status: UnAssn Submitter: techsupp ChangedBy: davidg RelatedBugIDs: 5793 5312 OS: Windows 2000 FixedDate: '2000-10-25' ClosedDate: '2000-10-25' Name: David Gravereaux CVS: updated saturday CustomShell: my tclAsync.c patch Comments: This appears to be working with SetConsoleCtrlHandler and the CtrlHandler returning TRUE, so Win32 doesn't kill it. I think I was being too aggressive with CloseHandle(GetStdHandle(STD_INPUT_HANDLE)); as Tcl_Gets in Tcl_Main was properly dropping-out. The tclWinNotify.c change is there just for the DLL as that's a possible senario with a threaded build. ObservedBehavior: Ctrl+C crashes tclsh84.exe rather then a clean exit. Patch: *** win/tclAppInit.c1999/12/02 02:03:371.6 --- win/tclAppInit.c2000/06/05 00:50:23 *************** *** 29,35 **** --- 29,39 ---- #endif /* TCL_TEST */ static voidsetargv _ANSI_ARGS_((int *argcPtr, char ***argvPtr)); + static BOOL __stdcallsigHandler _ANSI_ARGS_((DWORD fdwCtrlType)); + Tcl_AsyncHandlerexitToken; + Tcl_AsyncProcasyncExit; + /* *---------------------------------------------------------------------- *************** *** 156,161 **** --- 162,170 ---- Procbodytest_SafeInit); #endif /* TCL_TEST */ + SetConsoleCtrlHandler(sigHandler, TRUE); + exitToken = Tcl_AsyncCreate(asyncExit, (ClientData) interp); + /* * Call the init procedures for included packages. Each call should * look like this: *************** *** 298,301 **** --- 307,375 ---- *argcPtr = argc; *argvPtr = argv; + } + + /* + *---------------------------------------------------------------------- + * + * asyncExit -- + * + *The AsyncProc for the exitToken. + * + * Results: + *doesn't actually return. + * + * Side effects: + *tclsh cleanly exits. + * + *---------------------------------------------------------------------- + */ + + int asyncExit (ClientData clientData, Tcl_Interp *interp, int code) + { + char *buffer = "exit -1"; + Tcl_Eval((Tcl_Interp *) clientData, buffer); + + /* NOTREACHED */ + return code; + } + + /* + *---------------------------------------------------------------------- + * + * sigHandler -- + * + *Signal handler for the Win32 OS. Catches Ctrl+C, Ctrl+Break and + *other exits. This is needed so tclsh can do it's real clean-up + *and not an unclean crash terminate. + * + * Results: + *TRUE. + * + * Side effects: + *effects the way the app exits from a signal. This is an + *operating system supplied thread and unsafe to call ANY + *Tcl commands except for Tcl_AsyncMark. + * + *---------------------------------------------------------------------- + */ + + BOOL __stdcall sigHandler(DWORD fdwCtrlType) + { + /* + * If Tcl is currently executing some bytecode or in the eventloop, + * this will cause Tcl to enter asyncExit at the next command + * boundry. + */ + Tcl_AsyncMark(exitToken); + + /* + * This will cause Tcl_Gets in Tcl_Main() to drop-out with an <EOF> + * should it be blocked on input and our Tcl_AsyncMark didn't grab + * the attention of the interpreter. + */ + /* CloseHandle(GetStdHandle(STD_INPUT_HANDLE)); */ + + /* indicate to the OS not to call the default terminator */ + return TRUE; } *** win/tclWinNotify.c1999/07/02 22:08:281.5 --- win/tclWinNotify.c2000/06/05 00:50:37 *************** *** 150,155 **** --- 150,163 ---- { ThreadSpecificData *tsdPtr = (ThreadSpecificData *) clientData; + /* + * Should the operating system call DllMain with + * DLL_PROCESS_DETACH from any alternate thread path, such + * as Task Manager terminating the process, tsdPtr will + * be NULL and invalid. + */ + if (tsdPtr == NULL) return; + DeleteCriticalSection(&tsdPtr->crit); CloseHandle(tsdPtr->event); PatchFiles: win/tclAppInit.c win/tclWinNotify.c - foundin changed to: "obsolete: 8.4a1"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "nobody"
- subsystem changed to: "49. Threading"
- title changed to: "fix proposal for TR#5312 (part 2)"
- type changed to: "Bug"