Operating System - Linux
1828923 Members
2358 Online
109986 Solutions
New Discussion

Re: Is it possible to show what file a process i waiting for?

 
JanN
Occasional Contributor

Is it possible to show what file a process i waiting for?

I have a hung process.
It's showing state "D" in ps auxw
lsof shows all open files/socket
But how can I tell which one it is hanging for?

The only suggestion I have is using a debugger.
Can this information be collected from the kernel using some tool?
7 REPLIES 7
Steven E. Protter
Exalted Contributor

Re: Is it possible to show what file a process i waiting for?

Shalom,

The best utility for this is lsof.

It has a number of options to show what resouces are associated with a process.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Ivan Ferreira
Honored Contributor

Re: Is it possible to show what file a process i waiting for?

You can use strace or ltrace to view what is doing your process.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
JanN
Occasional Contributor

Re: Is it possible to show what file a process i waiting for?

Well - with LSOF i didn't find any flag to have it show me WHAT file/socket the process is hanging on.
I might have to re-read the man page or read the source...

When it comes to strace/ltrace, I don't know when this happens (not reproducable) and I cant run this process with strace all the time.
And when it have hung it stays hung!

/JanN

Jaime Bolanos Rojas.
Honored Contributor

Re: Is it possible to show what file a process i waiting for?

JanN,

This is one of the places where you can find the software:

http://freshmeat.net/projects/lsof/

Regards,

Jaime.
Work hard when the need comes out.
Ivan Ferreira
Honored Contributor

Re: Is it possible to show what file a process i waiting for?

You can wait to the process to hang and then run strace -p PID to attach to the process, there is no need to start the process with strace.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Tom Robinson_1
Advisor

Re: Is it possible to show what file a process i waiting for?

Processes in state 'D' are waiting on a 'slow' device. Essentially this means that the process has given control to the hardware and has gone to sleep. State 'D' is an 'un-interruptible' state. No amount of killing will have any effect until the hardware returns control to the process. The process can still ignore signals of course, except SIGKILL, which should pend on the return of control to the process. Processes in state 'D' should eventually wake up but if they don't you'll have to reboot.

lsof will show files but if your process is waiting on hardware then you'll just have to wait.
JanN
Occasional Contributor

Re: Is it possible to show what file a process i waiting for?

So far - the answers I got didn't really help me.

Ivan: I can attach strace on the fly - but then I've already missed the interesting system call that hung the process.

Steven et.al.: I already have lsof and know it is a handy tool. But I can't seem to find the answer to my question with it.

Tom: You're explaining it well - but I already knew that.

Questions are:
1. Can lsof (or any other tool) tell me (on the already hung process) what system call or file descriptor it is waiting for?

2. I cant use gdb since I can't signal the process. (Uninteruptable sleep) So I take it the only possible way is to poke into process or kernel memory somehow to find out. How can this be done?

Or is this a dead end? Must I either "crash" the whole system and look through the system dump or trouble shoot from another direction?

/JanN