Problems with ProcessMonitor

Dec 2, 2008
226
2
Canada
I created two simple BTM files to demo the problem, Monitor.btm and Monitor2.btm. In Monitor.btm the HUNG option for PROCESSMONITOR just doesn't work, PROCESSMONITOR thinks the program is always hung while Monitor2.btm does not. In both .BTM work fine. I noticed for Monitor2 there is an extra copy of TCC loaded (see the attached JPG files).

I also notice that for HUNG _processcount does not get created, see the output files (CrashFromMonitor.txt and CrashFromMonitor2.txt). When the program crashes _processname and _processpid seem to get lost but _processcount is available. I used SetLocal/EndLocal in the .BTM but if removed the same issues occur.

View attachment Crashed.BTM

View attachment CrashFromMonitor2.txt

View attachment CrashFromMonitor.txt

View attachment Hung.btm

View attachment Monitor2.btm

I'll attach more in next message.

Craig
 
Dec 2, 2008
226
2
Canada
More Files

The Test program is just

#include "stdafx.h"
#include <iostream>
using namespace std ;
int _tmain(int argc, _TCHAR* argv[])
{
unsigned long i = 0 ;
while (true)
{
cout << i++ << " " ;
}
}


I used to Ctrl-C to crash it.

Craig
 

Attachments

  • Monitor.btm
    274 bytes · Views: 74
  • Monitor..JPG
    Monitor..JPG
    8.3 KB · Views: 75
  • Monitor2..JPG
    Monitor2..JPG
    9.9 KB · Views: 71

rconn

Administrator
Staff member
May 14, 2008
12,356
150
I created two simple BTM files to demo the problem, Monitor.btm and Monitor2.btm. In Monitor.btm the HUNG option for PROCESSMONITOR just doesn't work, PROCESSMONITOR thinks the program is always hung while Monitor2.btm does not. In both .BTM work fine. I noticed for Monitor2 there is an extra copy of TCC loaded (see the attached JPG files).

I also notice that for HUNG _processcount does not get created, see the output files (CrashFromMonitor.txt and CrashFromMonitor2.txt). When the program crashes _processname and _processpid seem to get lost but _processcount is available. I used SetLocal/EndLocal in the .BTM but if removed the same issues occur.

No bugs here.

First, the HUNG option *does* work, but the way it works is by querying the app (via a SendMessageTimeout WM_NULL), and if it doesn't respond in 5 seconds, PROCESSMONITOR assumes it's hung. In your sample, you generated a console app with an infinite loop which never responds to anything in its message queue, so Windows gets no response and assumes it's hung.

In the case of MONITOR2.BTM, the reason it doesn't appear hung is your START statement *requires* a second TCC (to handle the internal commands in your command group), and PROCESSMONITOR is querying TCC (which does respond to messages), not your infinitely-looping-and-never-responding console app.

For STARTED and HUNG, the _processcount variable is not created, because it would always be 1.

I presume when you say "crashed" you actually mean "ENDED" (which is what a ^C will do). %_processname and %_processpid do not get created on an "ENDED" because, well, the process has ended and it has no name or pid!
 
Dec 2, 2008
226
2
Canada
No bugs here.

First, the HUNG option *does* work, but the way it works is by querying the app (via a SendMessageTimeout WM_NULL), and if it doesn't respond in 5 seconds, PROCESSMONITOR assumes it's hung. In your sample, you generated a console app with an infinite loop which never responds to anything in its message queue, so Windows gets no response and assumes it's hung.

In the case of MONITOR2.BTM, the reason it doesn't appear hung is your START statement *requires* a second TCC (to handle the internal commands in your command group), and PROCESSMONITOR is querying TCC (which does respond to messages), not your infinitely-looping-and-never-responding console app.

For STARTED and HUNG, the _processcount variable is not created, because it would always be 1.

I presume when you say "crashed" you actually mean "ENDED" (which is what a ^C will do). %_processname and %_processpid do not get created on an "ENDED" because, well, the process has ended and it has no name or pid!

The test program was a demo program for another issue. I have four server console processes that I am monitoring that have this same problem. I do have access to the source for these process, what would I have to add to their message handling, so that they could respond to TCMD query?
 

rconn

Administrator
Staff member
May 14, 2008
12,356
150
The test program was a demo program for another issue. I have four server console processes that I am monitoring that have this same problem. I do have access to the source for these process, what would I have to add to their message handling, so that they could respond to TCMD query?

The key is in the documentation for PROCESSMONITOR:

"HUNG will test the process's main window to see if it is still responding to messages".

Your average console app does not have a main window -- the window is owned by the Windows console manager, and it does all of the message handling.

I can think of three possible workarounds -- one is to change the console apps to GUI apps (with a hidden window & a message loop). A second is to convert them to hybrid apps (i.e., console apps with a window or GUI apps with a console -- this is what TCC does). Third, you could create a message hook and intercept & respond to the WM_NULL message.

 
Dec 2, 2008
226
2
Canada
The key is in the documentation for PROCESSMONITOR:

"HUNG will test the process's main window to see if it is still responding to messages".

Your average console app does not have a main window -- the window is owned by the Windows console manager, and it does all of the message handling.

I can think of three possible workarounds -- one is to change the console apps to GUI apps (with a hidden window & a message loop). A second is to convert them to hybrid apps (i.e., console apps with a window or GUI apps with a console -- this is what TCC does). Third, you could create a message hook and intercept & respond to the WM_NULL message.


So when earlier, I mentioned two version where one seemed to work, the second copy on TCC was acting as the console manager and was responding to the requests made from the other TCC session that had called PROCESSMONITOR. So how does this relationshilp work PROCESSMONITOR syntax uses the executables name for defining the process that it monitor and in this case it was TEST.EXE. If PROCESSMONITOR doesn't find a Console Manager is the current process does it the look in the parent process? Would console manager copy of TCC know if child process has hung, it seem to know that it terminates?

Craig
 

rconn

Administrator
Staff member
May 14, 2008
12,356
150
So when earlier, I mentioned two version where one seemed to work, the second copy on TCC was acting as the console manager and was responding to the requests made from the other TCC session that had called PROCESSMONITOR. So how does this relationshilp work PROCESSMONITOR syntax uses the executables name for defining the process that it monitor and in this case it was TEST.EXE. If PROCESSMONITOR doesn't find a Console Manager is the current process does it the look in the parent process? Would console manager copy of TCC know if child process has hung, it seem to know that it terminates?

The console manager is part of Windows, not part of any other app (including TCC or TCMD).

PROCESSMONITOR isn't looking for a console manager, it's looking for the owner of the main window of the process (which in this case is a console process owned by the console manager).

As I said before, the HUNG option is intended for GUI apps, not console apps (which generally do not process any messages, and which do not have access to their message queues). There is no documented way in Windows to determine whether console apps have hung.
 
Similar threads
Thread starter Title Forum Replies Date
Charles S. Roaten Problems with TCSTART.BTM Support 1
vefatica Office problems better Support 0
Peter Murschall TCC V26.01.3x Debugging has problems with Alias /R Support 1
Peter Murschall CMDebug 26.01.37 has problems with Alias Support 21
C unzip problems Support 2
C TCC 26 BATCOMP BTM problems? Support 5
Alpengreis WAD [v26 Beta RC3]: MSGBOX color problems Support 4
Alpengreis QUERYBOX problems Support 5
R New Cloud Storage Tab in TCC options causing problems Support 0
Craig Fitzgerald Problems using tcstart.btm Support 3
M Problems with @REGBREAD on remote system Support 4
K_Meinhard Help problems Support 3
S Problems with dir command in the debugger Support 5
D How to? Path problems in TCC20 Support 1
G Version 20.11 installed on Windows 10 problems Support 9
M WAD Set statements in () causes problems Support 8
M Fixed Set "VAR=VAL" format causes problems Support 12
H Problems with PSUBST Support 3
Alpengreis The TCMD Display problems and font size ... Support 2
cgunhouse Problems With IFTP Support 3
Gamegod Fixed TCC identify Chinese problems Support 30
vefatica 21-22 Update problems Support 8
T Problems with the new help format Support 18
cgunhouse Event Plugin Problems With 19.10.43 Support 2
C @replace and @xreplace problems Support 5
Alpengreis Forum problems? Support 0
N Fixed Problems with SHA256/384/512 Support 5
Alpengreis [TC 19.0 Beta 22/23] Install/Update-"Problems" Support 4
P Problems registering Support 5
R Parser problems after build 44 Support 5
LowdhamStation Serial port problems Support 7
vefatica Is jpsoft.com having ISP problems? Support 10
M Problems when being logged in Support 4
vefatica Both IFTP problems remain in build 50 Support 35
vefatica IFTP problems (broken pipe?) Support 24
Joe Caverly VIEW window in a TCC tab window problems Support 5
S Forum Implementation Problems Support 2
S Forum (XenForo) problems Support 3
S Problems to create new threads Support 6
S Fixed CLIPMONITOR problems Support 9
Roedy WAD Minor long-standing install problems Support 6
E Problems with Tabbed Toolbar Support 2
S Log and foldermonitor problems Support 3
vefatica Installation problems Support 1
J Problems for a neophyte Support 30
C Active FTP Problems Support 4
J Still problems understanding "foldermonitor" Support 9
J syntax problems multiple commands (command & command) Support 4
J 4NT problems after going to Windows 7 Support 5
vefatica Installer problems Support 23

Similar threads