When I do 'top' , I see my perl script process in 'S' state. Is there a way to know, what is making this perl process go in sleep state and ways to wake it up? Any way to debug to give more insights on lines in perl script making it go in 'S' state.
Processes go to sleep states when they are waiting for something, usually I/O.
Your process will be in
You can't "wake it up" - it will only proceed when the data/resource it is waiting for becomes available.
This is all normal and expected, and not usually a problem. Typically, this "program" run on the command line with no file:
will spend most of its time in sleep state, which is good - you don't want it to waste CPU while it's waiting for user input.
If you think this is a problem, try changing the way you do your I/O (reading larger chunks, in nice multiples of the underlying device's block size, doing memory mapped I/O, etc.).
A process in
You can use strace -p
which means that the process is trying to write 4096 bytes starting with "foobar" to stdout (fd #1) but whatever it has been redirected into is busy and the output buffer is full.