I'm using below cmd to get data from remote server using SSH in perl :

my $o = `ssh -n -x -q -o StrictHostKeyChecking=no -o BatchMode=yes - +o ConnectTimeout=5 host /script 2>/dev/null`; <code> <p> then, I process the $o and print to STDOUT . Now, the problem here is, when the data returned by the ssh is huge, t +hen, the perl program hangs forever. I did truss of the process id, it shows output like </p> <c> read(3, 0x001DF90C, 5120) = 5120 ---chunk of data from remote host --- brk(0x001E2470) = 0 brk(0x001E2470) = 0 brk(0x001E4470) = 0 read(3, 0x001DF90C, 5120) = 5120 ---chunk of data from remote host --- ---above continues until all data from rhost is read --- ---then starts write operation : write(4, 0x00229D64, 5120) = 5120 ---writes chunk of data read from rhost ---does for some more chunks then hangs forever--- write(4, 0x00229D64, 5120) (sleeping...)

I also found out that the ssh process created by the perl program is not hanging.
Is there problem in storing huge data into a variable (memory) in perl ? Here's the ulimit of the system :

time(seconds) unlimited file(blocks) unlimited data(kbytes) unlimited stack(kbytes) 8192 coredump(blocks) unlimited nofiles(descriptors) 4096 vmemory(kbytes) unlimited

Need your help in sorting the problem.


In reply to perl hangs on write syscall by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.