TPIPE.EXE crashes on Ctrl-C

May 20, 2008
11,411
99
Syracuse, NY, USA
TPIPE.EXE always crashes on Ctrl-C.

This was first reported five years ago ... and again during the v21 beta ... something to do with textpipeengine.dll and a console ctrl handler. Did you ever mention it to the developers? ... get a response?

FWIW,

Problem signature:
Problem Event Name: APPCRASH
Application Name: TPIPE.EXE
Application Version: 0.0.0.0
Application Timestamp: 597cd960
Fault Module Name: KERNELBASE.dll
Fault Module Version: 6.1.7601.17932
Fault Module Timestamp: 503275ba
Exception Code: 0eedfade
Exception Offset: 0000d3cf
OS Version: 6.1.7601.2.1.0.256.48
Locale ID: 1033

Read our privacy statement online:
http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409

If the online privacy statement is not available, please read our privacy statement offline:
C:\Windows\system32\en-US\erofflps.txt
---------------------------
Error
---------------------------
Runtime error 217 at 00011AEC
---------------------------
OK
---------------------------
 
May 20, 2008
11,411
99
Syracuse, NY, USA
(Subtitle: aliases and line continuations?)

My problem occurs when /output is not specified. Then, TPIPE starts a new TCC to TYPE a tmp-file containing the output (question: Why doesn't TPIPE.EXE just exit after starting that TCC?).

I've had some success with this alias.
Code:
v:\> alias ctpipe
tpipe /output=%temp\ctpipe.tmp %$ & type %temp\ctpipe.tmp

Somewhat to my surprise, it works here.
Code:
echo %@execarray[l,ctpipe /input=h:\temp\ksyr.tmp ^
   /grep=3,0,0,1,0,0,0,0,"right.*left" ^
   /replace=4,1,0,1,0,0,0,0,0,".*([0-9][0-9]:[0-9][0-9]).*td.(-*[0-9]*)..td..td.*[0-9]*..td.$","$1  $2" ^
   /head=0,0,24] > NUL
After that pleasant surprise, I was disappointed that it failed here, with TPIPE getting a raw '^' as a parameter:
Code:
ctpipe /input=h:\temp\forecast.tmp ^
   /grep=3,0,0,1,0,0,0,0,"High: \d+|Low: [-]*\d+" ^
   /simple=16 ^
   /replace=4,0,0,0,0,0,0,0,0," &",\n ^
   /replace=4,1,0,0,0,1,0,0,0,"High.*$|Low.*$",$0\n ^
   /simple=12 ^
   /replace=0,1,0,1,0,0,0,0,0,"Low: ","Low:  "

I fixed that with parentheses; this one works:
Code:
(ctpipe /input=h:\temp\forecast.tmp ^
   /grep=3,0,0,1,0,0,0,0,"High: \d+|Low: [-]*\d+" ^
   /simple=16 ^
   /replace=4,0,0,0,0,0,0,0,0," &",\n ^
   /replace=4,1,0,0,0,1,0,0,0,"High.*$|Low.*$",$0\n ^
   /simple=12 ^
   /replace=0,1,0,1,0,0,0,0,0,"Low: ","Low:  ")

So what's going on in the failing case; why aren't the line continuations honored?
 
May 20, 2008
11,411
99
Syracuse, NY, USA
Here's a simplification of that behavior. Why isn't the line continuation honored in the "zztest.btm" example?
upload_2017-8-2_20-34-53.png
 
May 20, 2008
11,411
99
Syracuse, NY, USA
Back to the original problem, TPIPE.EXE crashing. The text processing itself is very fast. It's console output that I want to interrupt (especially when testing with a big (real thing) file).

Can't TPIPE.EXE do this?

If it's going to start a TCC to TYPE a temp file ...
Just before starting that TCC ...
Add a console ctrl handler that does nothing but return TRUE ...

That will prevent textpipeengine's handler from being called and allow processing to continue. The TCC doing the outout will exit because of the signal, and TPIPE.EXE will terminate normally.

I can Ctrl-C out of TPIPE console output with no crash after injecting this DLL into TPIPE.EXE.

Code:
#include <windows.h>

BOOL WINAPI CtrlHandler ( DWORD dwSignal )
{
   return TRUE;
}

BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved )
{
   if ( dwReason == DLL_PROCESS_ATTACH )
       SetConsoleCtrlHandler(CtrlHandler, TRUE);
   return TRUE;
}
 
May 20, 2008
11,411
99
Syracuse, NY, USA
Or, under the same circumstances, just tell TPIPE.EXE to ignore Ctrl-C. Injecting this DLL also works.

Code:
#include <windows.h>

BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved )
{
   if ( dwReason == DLL_PROCESS_ATTACH )
       SetConsoleCtrlHandler(NULL, TRUE);
   return TRUE;
}
 
Similar threads
Thread starter Title Forum Replies Date
vefatica WAD TPIPE.EXE has stopped working Support 13
samintz How to? TPIPE /simple=61 Support 6
R Bug TPIPE's pdf to text conversions don't work Support 2
Kachupp How to? tpipe Support 4
H TPIPE /simple=4 Support 12
D TPIPE produces unwanted logs. Support 1
Kachupp How to? tpipe Support 8
vefatica Documentation TPIPE, /perl, DotMatchesNewLines Support 1
vefatica Stop TPIPE /EOL removing bad EOLs (and TPIPE changine EOLs)? Support 2
vefatica TPIPE in an alias? Support 2
C How to? TPIPE ?'s Support 2
H History and TPipe Oddness Support 3
Jay Sage Baffling Behavior With TPIPE Support 5
vefatica TPIPE: unbalanced escaped quotes in a regex? Support 5
Joe Caverly Multiple Text Searches at once using FFIND or TPIPE Support 4
Kachupp FFIND TPIPE Support 9
vefatica TPIPE and avarice? Support 5
Peter Murschall TPIPE generate unicode on Piping or redirecting Support 3
x13 TPIPE /REPLACE - Remove line (including EOL) Support 3
Charles Dye Documentation TPIPE /REPLACELIST Support 0
Joe Caverly TPIPE and /inputstring Support 3
vefatica How to? Add real <ESC> characters with TPIPE Support 2
vefatica How to? TPIPE ... see output right away? Support 4
O TPIPE: Error -Can´t access textpipeengine.dll Support 24
vefatica Extract fields with TPIPE? Support 10
vefatica TPIPE, crash and question Support 1
MickeyF Another TPIPE question Support 6
MickeyF Can't get my TPIPE /replace to work Support 4
Joe Caverly Printing TPIPE documentation Support 3
C WAD tpipe /simple=28 Support 8
vefatica Remove double-quotes with TPIPE Support 4
vefatica TPIPE crashes on Ctrl-C Support 1
C How to? Add date/time to custom tpipe based BTM Support 1
C tpipe /simple=28 error Support 5
C TPipe /dup Support 5
T TPipe: Replacing String with Double Quotes Support 3
C tpipe and extract email addresses Support 1
vefatica How do I do this with TPIPE? Support 1
vefatica TPIPE's /perl option? Support 1
D TPIPE help typo Support 0
vefatica TPIPE access violations are back Support 2
Joe Caverly Word Count using TPIPE Support 10
Dan Glynhampton TPIPE in Build 41 Support 4
Phileosophos TPIPE doesn't work at all with v16 Support 3
vefatica TPIPE access violation again Support 1
David McClelland TPIPE matching problem Support 3
vefatica TPIPE: Access violation Support 5
jbanaszczyk TCMD 16 - TPIPE Support 4
P TPipe relaunches TCC window and 4start, etc Support 7
Phileosophos Documentation TPIPE /string type code confusion Support 4

Similar threads