Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Broken pipe problem? If so, why?

Reply
Thread Tools

Broken pipe problem? If so, why?

 
 
malgosia askanas
Guest
Posts: n/a
 
      03-28-2005
I have a mail-handling program written in Perl. It gets passed a mail message,
reads the header, does some processing, and exits. The code for reading
the header is:

$/ = ''; # paragraph mode
$header = <>;

I am invoking this program in a pipe from procmail. For some messages (I
believe, for very large ones) I get the message "Error while writing to
<progname>" in the procmail log. I would be inclined to believe that it's
a broken pipe problem, but if so, why does its occurrence depend on the
message size? The program reads only the header for _all_ messages,
independent of size - yet in a vast majority of cases, procmail does not
complain. Can you advise?


Many thanks in advance,
-malgosia
 
Reply With Quote
 
 
 
 
Big and Blue
Guest
Posts: n/a
 
      03-28-2005
malgosia askanas wrote:
>
> $/ = ''; # paragraph mode
> $header = <>;
>
> I am invoking this program in a pipe from procmail. For some messages (I
> believe, for very large ones) I get the message "Error while writing to
> <progname>" in the procmail log. I would be inclined to believe that it's
> a broken pipe problem, but if so, why does its occurrence depend on the
> message size? The program reads only the header for _all_ messages,
> independent of size - yet in a vast majority of cases, procmail does not
> complain. Can you advise?


The fact that you "only" read the header is the problem (but reading
all of it is not necessarily the solution).

procmail is piping the message to you (can't you configure procmail
just to send teh header?). If the entire message is small enough to fit
into the buffer of a pipe (usually 8kB?) then it will write it all and
things are OK. If it is larger than this though a problem occurs - you
only read the start of the then close the pipe (by exiting). Since you
have closed the pipe while procmail still has it open *it* gets sent a SIGPIPE.

So, you have to look at the procmail config options and:

1) get it to only send headers - if possible only get it to send
information you are interested in.
2) tell it to ignore SIGPIPE if possible

if 2) is not possible then you should read *everything* (but just ignore
the parts aftre the bit you really want).




--
Just because I've written it doesn't mean that
either you or I have to believe it.
 
Reply With Quote
 
 
 
 
xhoster@gmail.com
Guest
Posts: n/a
 
      03-28-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) (malgosia askanas) wrote:
> I have a mail-handling program written in Perl. It gets passed a mail
> message, reads the header, does some processing, and exits. The code for
> reading the header is:
>
> $/ = ''; # paragraph mode
> $header = <>;
>
> I am invoking this program in a pipe from procmail. For some messages (I
> believe, for very large ones) I get the message "Error while writing to
> <progname>" in the procmail log. I would be inclined to believe that
> it's a broken pipe problem, but if so, why does its occurrence depend on
> the message size? The program reads only the header for _all_ messages,
> independent of size - yet in a vast majority of cases, procmail does not
> complain. Can you advise?


Since your Perl program is only reading the header, it must be terminating
while there is still stuff to be read. For short messages, all that stuff
to be read fits in the buffer, so the other end of the pipe doesn't notice.
But for large messages, when the Perl end of the pipe exits the other end
of the pipe gets upset because it is now trying to write to something that
no longer exists. Or something like that.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[named pipe] i wanna know about validate of pipe handle of client lee, wonsun C++ 1 11-02-2004 04:29 AM
Why does IO::Pipe::END generate an EXCEPT pipe message? lvirden@gmail.com Perl Misc 1 06-02-2004 02:17 PM
how to detect broken pipe ? funtoosh Perl 1 12-21-2003 04:08 PM
terrible java.net.SocketException: Broken pipe, please HELP!! Tomas Penc Java 3 10-24-2003 09:22 AM
broken pipe error messages thrown by tomcat -- how to suppress? Clive Java 0 08-12-2003 01:42 PM



Advertisments