views:

67

answers:

2

Hello,

How do I know is there my child process got hang while operating?

+1  A: 

I guess, you are asking, how do you find if the child process is hung while operating. You can't tell easily. A process could be doing a long running operation. The context is important to understand when a process is hung.

If you are expecting a process to respond to a user input and is not responsive for a long period then we consider it hung. Process is running probably waiting for some thing that will never happen. "Hung Process" is humanly way of saying that a program has reached a dead end and will be no more useful.

You could have a program calculating prime numbers one after another and can run for eons and can not be called a hung process.

pyfunc
Ok. First we can set default timeout, and then terminate process if needed. Is this true?
sultan
Yes But default time out can be determined by user only in context. As I had mentioned in my reply, If you are calculating large primes, it can take a lot of time. So the context is determined from what the program is doing and reasonable guess on it's conclusion.
pyfunc
I try to use browser's core to render some content inside subprocess.
sultan
+2  A: 

Well, how do you tell the difference between a stuck process and a process that takes longer than usual to complete? The short answer is: No, you can't detect if your child process is stuck.

I would say that to be able to detect this you need some kind of continuous communication with the process (e.g. look at log files, IPC or similar). Based on this communication you might be able to tell when and if a process is stuck.

Arlaharen
How to use communication in case of nested subprocesses? The reason I pick some module's in subprocess and it makes it's own subprocess in turn.
sultan
Every process has a parent and nested subprocesses have their parent. Create pipes (IPC) as mentioned in the reply. Write and receive from these between the processes and when they are broken and you can't read and write from them, you can consider the process hung.
pyfunc
I'll care about IPC from now. Thanx!
sultan
Also what to do if parent thinks about subprocess is still working though subprocess just slept or hung?
sultan