Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How can I control process termination timeout ?

Posted on 1998-11-13
8
Medium Priority
?
646 Views
Last Modified: 2013-12-03
Hi,

I am using NT4.0 and I have the following question regarding to process control.

1. When we stop a process from task manager, if this process fails to respond, after certain time, we get a dialog box saying something like "wait..." or "End task", etc. How can we control this timeout ? I guess if we choose EndTask, NT will call TerminateProcess() to kill the process. But in some case, the process will still hang over there. Any way to handle this problem ?

2. When we stop a service from SCM, again, we will get a dialog box complaining the NT service is not responding in a certain time. How can we control this timeout ?

3. When we "Shutdown the computer", there is a certain timeout again. How can we control that ? Also, from a program, how can I issue a Shutdown the computer command ?

Any help is greatly appreciated.


Mike


0
Comment
Question by:mikechen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 20

Expert Comment

by:Madshi
ID: 1416061
I don't know if you can control the timeout times of the task manager or of SCM (whatever this is...) or of the explorer's shutdown. Perhaps there are some registry settings, but I don't know them...
However, if you use TerminateProcess yourself, there'll be no delay. If the process then still hangs, you can't do nothing more. But in most most most cases TerminateProcess should work. Though, it's a very unkind way of ending processes, since the dlls of the terminated process have no chance to gracefully shut down.
I'm not so sure about the services. But AFAIK, services are just specific applications, so it will be the same as above...
To shutdown the computer from your program, use ExitWindowsEx(...). There will be no delay.

Regards, Madshi.
0
 

Author Comment

by:mikechen
ID: 1416062
Thank you for your response, Madshi.

Actually, I know the terminate timeout of a service can be controlled. And I know the terminate timeout of the whole system is set in one of the registry key. I just forgot the key in the registry.

So anybody can give me some idea ?

Thanks,

Mike

0
 
LVL 86

Expert Comment

by:jkr
ID: 1416063
Usually service's timeouts aer controlled by the service itself calling 'SetServiceStatus()' and setting the 'dwWaitHint' member of the 'SERVICE_STATUS' structure to the appropriate value (if the service reads this value from the registry, all is fine for you, but i usually hard-code this ;-). And, if you 'close' a process from the task manager, i primarily sends a 'WM_CLOSE' using 'SendMessageTimeout()' (if this times out, you'll get the 'not responding' dialog. 'Terminating' a process from the TM indeed means that it uses 'TerminateProcess()', giving the process no time to interact...
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 

Author Comment

by:mikechen
ID: 1416064
Thanks for your comment, jkr.

How about the whole system ? Does anybody know the registry ?

Thanks,

Mike

0
 
LVL 15

Accepted Solution

by:
NickRepin earned 600 total points
ID: 1416065
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\WaitToKillServiceTimeout

HKEY_USERS\.DEFAULT\Control Panel\Desktop\WaitToKillAppTimeout

HKEY_USERS\.DEFAULT\Control Panel\Desktop\HungAppTimeout

Little descriptions:

HungAppTimeout     REG_SZ

Range: Milliseconds (msec)

Default: 5000

Determines how long the system waits for user processes to end in response to the End Task button command in Task Manager. If this threshold is exceeded, the End Task dialog box appears stating that the process did not respond or, if AutoEndTasks is enabled, the system ends the process automatically.

WaitToKillAppTimeout     REG_SZ

Range: Milliseconds

Default: 20000

Determines how long the system waits for user processes to end after the user attempts to log off or to shut down Windows NT.  If this threshold is exceeded, the End Task dialog box appears stating that the process did not respond or, if AutoEndTasks is enabled, the system ends the process automatically.


AutoEndTasks     REG_SZ    

Range: 0 or 1

Default: 0 (disabled)

Determines whether user processes are ended automatically when the user logs off or stops Windows NT. If the value of this entry is 1 (or other than 0), processes are ended automatically. If it is set to 0, the system waits until the process ends and, if the process exceeds the timeout threshold (HungAppTimeout), the End Task dialog box appears stating that the application cannot respond to the End Task request.


0
 

Author Comment

by:mikechen
ID: 1416066
Thank you for your response, NickRepin.

I remember there is another registry value controls the shutdown timeout of the whole system. I am not sure whether it is .

\HKEY_LOCAL_MACHINE\SYSTEMS\CurrentControlSet\Control\Windows\ShutdownTime  

Do you know how to interpret this value ?

Thanks again,

Mike
0
 
LVL 15

Expert Comment

by:NickRepin
ID: 1416067
Its just a shutdown time. :)
The time when NT was turned off. In FILETIME struct.

If you are talking about the timeout for 'end task' request while shutdown, its exactly the same as for HungAppTimeout and controlled by this registry key. See description of AutoEndTask in my answer.

0
 

Author Comment

by:mikechen
ID: 1416068
Thank you, NickRepin.

Mike

0

Featured Post

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question