Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Perl: porters

[perl #54644] Perl script hang at while statement

 

 

Perl porters RSS feed   Index | Next | Previous | View Threaded


perlbug-followup at perl

May 22, 2008, 9:15 AM

Post #1 of 3 (195 views)
Permalink
[perl #54644] Perl script hang at while statement

On Thu May 22 06:11:20 2008, chaitanyav[at]in.ibm.com wrote:
>
>
> Hello,
> I have a problem with the Perl script.
> I attached the file below created by perlbug -v commad.
>
> (See attached file: bugrep0954564)
>
> Can you please help me in resolving this issue.
> Please let me know, if you need any more details of the issue or need to
> collect any more docs.
>
> And also please let me know, if these is not the correct correct/proper
> channel for support.
>
> Thanks & Regards,
> Chaitanya V


I think what would help the most in diagnosing the problem is a small
script that demonstrates the problem.

Thanks,

Steve Peters


perlbug-followup at perl

May 22, 2008, 6:11 AM

Post #2 of 3 (177 views)
Permalink
[perl #54644] Perl script hang at while statement [In reply to]

# New Ticket Created by Chaitanya Vutukuru
# Please include the string: [perl #54644]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=54644 >




Hello,
I have a problem with the Perl script.
I attached the file below created by perlbug -v commad.

(See attached file: bugrep0954564)

Can you please help me in resolving this issue.
Please let me know, if you need any more details of the issue or need to
collect any more docs.

And also please let me know, if these is not the correct correct/proper
channel for support.

Thanks & Regards,
Chaitanya V
Attachments: bugrep0954564 (29.9 KB)


sthoenna at efn

May 22, 2008, 11:18 PM

Post #3 of 3 (176 views)
Permalink
Re: [perl #54644] Perl script hang at while statement [In reply to]

On Thu, May 22, 2008 6:11 am, Chaitanya Vutukuru wrote:
> And also please let me know, if these is not the correct correct/proper
> channel for support.

This is the proper place for perl bug reports, but not general support
of perl. For help with perl programming, try http://perlmonks.org.

> Here is the brief explanation of the perl script and the problem
> we are facing:
> In the script we create pipe like:
> pipe(FROMDBREAD,FROMDBWRITE);
>
> we dup STDOUT and STDERR, to FROMDBWRITE pipe descriptor like:
> open(STDOUT,">&FROMDBWRITE") || die "$ME (child): can't redirect STDOUT\n";
> open(STDERR,">&STDOUT") || die "$ME (child): can't redirect STDERR\n";
>
> Then we will wait for the pipe descriptor in the while loop:
> while(<FROMDBREAD>) {
> ..
> ..
> }
>
> We know that few messages are loggedin STDOUT and STDERR, but we see
> that the script is hanging in the above while statement.
> We are telling it as a hang because its not coming out of that
> while(for false) or even not running the statements under that while
> (for true), it is just waiting at "while(<FROMDBREAD>)", which is
> leading to the whole script hanging.
> We and customer facing this issue in one particular scenario
> and in some machines.

I believe you are not understanding how pipes work; you may want to
unless you are in non-blocking mode, reading on a pipe will wait for
something to be written if there are any open write filehandles on
the pipe.

See http://www.opengroup.org/onlinepubs/009695399/functions/read.html
and/or try the following:

#!/usr/bin/perl
use strict;
use warnings;
my $ME = "me";

open OUT, ">&STDOUT" or die "couldn't dup\n";

pipe(FROMDBREAD,FROMDBWRITE);

#we dup STDOUT and STDERR, to FROMDBWRITE pipe descriptor like:
open(STDOUT,">&FROMDBWRITE") || die "$ME (child): can't redirect STDOUT\n";
open(STDERR,">&STDOUT") || die "$ME (child): can't redirect STDERR\n";

print OUT "warning foo\n";
warn "foo";
print OUT "warned foo\n";

$SIG{ALRM} = sub { close FROMDBWRITE; close STDOUT; close STDERR; print
OUT "closed\n" };
alarm 5;

#Then we will wait for the pipe descriptor in the while loop:
while(<FROMDBREAD>) {
print OUT "got :$_:\n";
}

print OUT "done\n";

Perl porters RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.