Solved

How can I control process termination timeout ?

Posted on 1998-11-13
8
545 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
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
 

Author Comment

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

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

Thanks,

Mike

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 15

Accepted Solution

by:
NickRepin earned 150 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

911 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now