IF command problem in tcexit.btm

May 31, 2008
62
0
Oklahoma
TCC 25.00.23 x64 Windows 10 [Version 10.0.18362.476]

For the following tcexit.btm
Code:
:: tcexit.btm
@ECHO OFF
echo Pipe %_pipe Trans %_transient > c:\Users\Public\test_output\1before_if
if %_pipe != "0" .or. %_transient != "0" quit
echo Pipe %_pipe Trans %_transient > c:\Users\Public\test_output\2after_if

If I exit an instance of TakeCommand by executing EXIT at the command prompt of the single remaining tab the following output occurs:​
Code:
 Directory of  C:\Users\Public\test_output\*

11/14/2019  20:03              16  1before_if
11/14/2019  20:03              16  2after_if
                  32 bytes in 2 files and 0 dirs

 >cat 1before_if
Pipe 0 Trans 0
 >cat 2after_if
Pipe 0 Trans 0

However, if I exit by clicking the X button window control or the X Close window option on the Taskbar icon or selecting the Menu Bar HOME EXIT option the following output occurs:​
Code:
 Directory of  C:\Users\Public\test_output\*

11/14/2019  20:46              16  1before_if
                  16 bytes in 1 file and 0 dirs

 >cat 1before_if
Pipe 0 Trans 0
Why isn't the second ECHO command executed for these exit cases??? :confused:
 
May 20, 2008
11,414
99
Syracuse, NY, USA
With a similar TCEXIT

Code:
set test=%[_PIPE]%[_TRANSIENT]
echo before: %_pid %test > v:\tcexit.log
if "%test" != "00" quit
echo after: %_pid %test >> v:\tcexit.log

I get both log entries (before/after) regardless of how I terminate TCC ... the EXIT command, X the console, X the TCMD tab, X TCMD, choose Home\Exit in TCMD.
 
May 31, 2008
62
0
Oklahoma
Perhaps if I had posted the actual - as executed tcexit.btm it would make more sense Guess I should have waited until morning to post the question! :oops:
Code:
:: tcexit.btm
@ECHO OFF
echo Pipe %_pipe Trans %_transient > c:\Users\Public\test_output\1before_if
if %_pipe != 0 .or. %_transient != 0 quit
echo Pipe %_pipe Trans %_transient > c:\Users\Public\test_output\2after_if

Note: The actual IF statement is identical to the example found in the HELP for TCSTART and TCEXIT.​

So -- Why isn't the second ECHO command executed for all of the exit cases??? :confused:
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,466
88
Albuquerque, NM
prospero.unm.edu
Okay. I can replicate this.

Here's a version that works as you would expect:
Code:
@ECHO OFF
echo Pipe %_pipe Trans %_transient > c:\Users\Public\test_output\1before_if
if "%_pipe" != "0" .or. "%_transient" != "0" quit
echo Pipe %_pipe Trans %_transient > c:\Users\Public\test_output\2after_if

And here is a version which displays the same behavior, but without the IF command:
Code:
@ECHO OFF
echo Pipe %_pipe Trans %_transient > c:\Users\Public\test_output\1before_if
echo %@eval[6 * 9]
echo Pipe %_pipe Trans %_transient > c:\Users\Public\test_output\2after_if

My wild-assed guess: When you exit by closing the console — the big red X — Windows kills the associated program very quickly, a fraction of a second. But when you use the EXIT command, there is no time limit; TCC can take as long as it wants. And I suspect that the parsing of numbers is pretty slow, due to the big-numbers support Rex added a few versions back.
 
May 31, 2008
62
0
Oklahoma
Okay. I can replicate this.
, , , ,
Thanks for taking the time to confirm my somewhat flawed report. If your surmise is correct then this really impairs the utility of tcexit.btm at least for my usage cases [and IMNSHO]. I don't want to count on winning a race against the OS -- we all know just who is going to win! :rolleyes:

I only noticed this behavior after upgrading to TakeCommand 25.00.23 x64 from 24.02.51 x64 and have no idea just how long this has been a feature? :smile:
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,466
88
Albuquerque, NM
prospero.unm.edu
Thanks for taking the time to confirm my somewhat flawed report. If your surmise is correct then this really impairs the utility of tcexit.btm at least for my usage cases [and IMNSHO]. I don't want to count on winning a race against the OS -- we all know just who is going to win! :rolleyes:

I only noticed this behavior after upgrading to TakeCommand 25.00.23 x64 from 24.02.51 x64 and have no idea just how long this has been a feature? :smile:
Don't know; I've never noticed it. And my guess as to what's going on could be completely wrong. Hoping to hear from Rex on this one.
 
May 20, 2008
11,414
99
Syracuse, NY, USA
Something peculiar is going on. With a simple PAUSE in TCEXIT, the TCC process terminates a full 5 seconds after any attempt to terminate (EXIT, X-ing the console, X-ing a TCMD tab, X-ing TCMD itself). So Windows is giving it the 5 (as advertised) seconds.

That all changes if, before the PAUSE, I put an "ECHO %@EVAL[]" statement (like Charles) ... then X-ing the console is immediate. It's not the time to execute the @EVAL ... "DELAY 1" does not have that effect.
 

rconn

Administrator
Staff member
May 14, 2008
12,363
150
An interesting Windows bug / undocumented behavior.

Windows is throwing an exception (in ntdll, not in the TCC code) if an EnterCriticalSection API call is made during the WM_QUERYENDSESSION processing. The math library is calling EnterCriticalSection to allow multithreading, so disabling the critical section calls will break other (more obvious) things.

I can add a kludge to turn off multithreading during shutdown (which *probably* won't break too many things).
 
May 31, 2008
62
0
Oklahoma
rconn said:
I can add a kludge to turn off multithreading during shutdown . . .

May we expect that to happen or will the Take Command/TCC HELP section TCC Termination Program be updated to clearly identify the only(?) case where the TCEXIT program can be expected to run to a normal exit? :smile:

Update: Of course Rex fixed this -- perhaps before I posted the comment. Next time I'll check updates before posting! :oops:
 
Last edited:
Similar threads
Thread starter Title Forum Replies Date
M Selecting test "off by one" problem in Take command Support 4
M Take Command 18, migrating to another machine, license problem. Support 1
Alpengreis Problem if command prompt is not legacy Support 4
M How to? Take Command\TCC install problem... Support 2
D Fixed Minor problem: output not alligned in the tree command Support 1
nikbackm v15: Problem with ALIAS in command group Support 10
Frank Problem with Window "Take Command Help" Support 3
M Problem with the "List" command... Support 19
K Take Command startup problem Support 7
V WAD SYNC command problem Support 2
M Wierd problem wih "for" command... Support 2
M Problem with the "List" command... Support 7
gschizas Command tail (%$ / %*) problem Support 5
Jay Sage TCMD11: Problem with PLUGIN Command Support 4
Roedy Command Line Quotiing Problem Support 1
Dmitry L. Kobyakov How to? How to remove the record of the old version of the Take Command? Support 9
D Can alias pass parameters to for command? Support 3
samintz How to? Search for %(command) in Help? Support 1
T VIEW only works from command line Support 14
rconn News Take Command / TCC / CMDebug / TCC-RT v28 Released Support 0
T Take Command 28: Lua reports version 5.4.0 (5.4.3 expected) Support 0
Jay Sage WAD Possible Bug With OPTION Command With @FILE Support 5
rconn News Take Command / TCC / CMDebug / TCC-RT 27.01.24 uploaded Support 0
J Take command does not start on Windows 10 Support 3
vefatica `Back quotes` - command line vs. batch file Support 5
Jay Sage WAD Failure of Alias Command with /Z Option Support 14
Phileosophos Is there any way to open the Take Command options dialog from the command line? Support 8
Phileosophos Command-line Editing Shortkeys That Fail Support 6
fpefpe How to? free (internal) command Support 0
rconn News Take Command / TCC / CMDebug / TCC-RT 27.01.23 uploaded Support 0
T How to? retain command history across reboot? Support 6
rconn News Take Command / TCC / CMDebug / TCC-RT v27.01 Build 22 Uploaded Support 0
Jay Sage Bug With Flow Control and/or Command Grouping Support 2
GermanDirk How to? EVENTLOG Command with simple User Rights not functional Support 4
Jay Sage Take Command Is Too Fast! Support 4
Jay Sage Comparison of IF with Command Group and IFF Support 6
D Open Windows 10 Photos app from command line Support 11
rconn News Take Command / TCC / CMDebug / TCC-RT 27.0.21 uploaded Support 0
rconn News Take Command / TCC / CMDebug / TCC-RT 27.0.20 uploaded Support 0
U Can not get/start Take Command gui Support 1
rconn News Take Command / TCC / CMDebug / TCC-RT 27.0.19 Support 0
S Increasing Font Point Size in Command Tabs Support 2
mfarah Fixed The DATE command produces the wrong error message. Support 1
vefatica Command name mix-up Support 3
FreezerBurnt "Missing SETLOCAL" when initializing Visual Studio Command Prompt. Support 9
E How to? Closing desktop created by DESKTOP command Support 10
rconn News Take Command / TCC / CMDebug / TCC-RT v27.0.18 Support 0
K Take Command fox XP? Support 7
Joe Caverly Documentation Replace internal command with LIBRARY command Support 0
fpefpe How to? command echo in title line/bar Support 2

Similar threads