in reply to perl process hangs after processing the last file.

Difficult (impossible?) to say without seeing your code. A typical cause of a hang might be waiting for a pipe to be closed by the writer or waiting on a signal.

You could try to use strace on the hanging process (strace -p pid) which could give you an idea.

we know this via logging mechanism
be careful, the log file might not be up-to-date if some records are waiting in a buffer. Check by switching off buffering if you can.
  • Comment on Re: perl process hangs after processing the last file.

Replies are listed 'Best First'.
Re^2: perl process hangs after processing the last file.
by avanta (Beadle) on Jan 18, 2011 at 13:44 UTC
    Hi cdarke, I cannot paste the code as its confidential. btw strace info is as follows:
    strace -fe verbose=all -p 19881 Process 19881 attached - interrupt to quit read(7, ls -l /proc/19881/fd/ total 0 lr-x------ 1 root root 64 Jan 17 20:02 0 -> pipe:[1771023532] l-wx------ 1 root root 64 Jan 17 20:02 1 -> pipe:[1771023666] l-wx------ 1 root root 64 Jan 17 20:02 2 -> pipe:[1771023533] lrwx------ 1 root root 64 Jan 17 20:02 3 -> socket:[1771025115] lr-x------ 1 root root 64 Jan 17 20:02 4 -> /opt/opwv/OKRAuser/3.1.1/E +TL/data/input/rba/abc.log.working lrwx------ 1 root root 64 Jan 17 20:02 7 -> socket:[1771023680]

    Thanks
    AvantA

        As a bonus, when you do reduce it to a minimal set of code, you often won't need to post it; the problem and its solution will have become obvious.

      OK, so it is reading file descriptor 7, which is a socket. So you need to look at your closedown sequence. How does the writer indicate that there is no further data? Does the reader check for this correctly?
        Hi cdarke,

        after some analysis I found the followin info
        lsof shows it's an IPv4 connection: perl 2221 root 7u IPv4 1768226357 TCP xyz-server.com:38178->xyz-server.com:7891 (ESTABLISHED) Connection to port 7891 - the JVM used /usr/java/jdk1.6.0_21/bin/java org.perl.inline.java.InlineJavaServer 0 + localhost 7891 true false false
        Actually, we are using Inline::Java to use methods in a jar file through perl, basically for SNMP usage. that is the reason for the creation of JVM which is in Shared mode. There is a method which uses the Java module in the 4th Step mentioned in my query above.

        This is called for all the text files but why is it hanging at the last process having the last file, if java module is the cause. So any suggestions on the same.
        Thanks
        AvantA