473,978 Members | 1,680 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to detect broken pipe ?

Hi

Scenario:

I have a shell script e.g. a.bash
This script wraps a program called "generate" like this:

generate > /tmp/y.txt 2>&1 # both stdout and stderr r redirected to
y.txt

Now , I have perl script e.g. myPerl.pl and I modify a.bash such that:

generate | perl myPerl.pl # pipe output from "generate" to the perl
script.

And in myPerl.pl, I wrote this :

sub whatSignal { print "caught ",shift, "\n" };
$SIG($_}=\ &whatSignal for keys %SIG

And now I run a.bash in one xterm:
Following happens:
When press ctrl-C, it is caught.

But when I kill pid of program "generate" from a different xterm, my
script doesnt detect "broken pipe" ?

Comments ?
Jul 19 '05 #1
1 9243

a_*******@yahoo .com (funtoosh) wrote:
generate | perl myPerl.pl # pipe output from "generate" to the perl
script.

And in myPerl.pl, I wrote this :

sub whatSignal { print "caught ",shift, "\n" };
$SIG($_}=\ &whatSignal for keys %SIG


You only get sent SIGPIPE when you write to a broken pipe. Reading
will simply return EOF.

This Is Not A Perl Question.

Ben

--
. | .
\ / The clueometer is reading zero.
. .
__ <-----@ __ be*@morrow.me.u k
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
12184
by: Frank de Bot | last post by:
Hi, occasionaly I find in my apache logs that fastcgi had a broken pipe error with php running as fastcgi. the logs are like this: -- > (32)Broken pipe: > FastCGI: comm with server /opt/guide/ppi.searchy.net/cgi-bin/php.fcgi" > aborted: write failed > FastCGI: incomplete
1
8201
by: Ruben | last post by:
I am reading a large text file a chunk at a time using the readlines(buffer_size) statement. I get an IOERROR ERRNO 32 Broken Pipe command when I "pipe" the output to MYSQL database using the following command: python script.py | mysql I am using RED HAT 9 Linux. The problem only happens if I use the pipe to MYSQL. It breaks but it gets to process around 1000 MYSQL statements.
2
8640
by: Nigel King | last post by:
I have a problem with the logging module. It reports a Broken Pipe error after outputing to the log file occasionally (5%). This does not appear to happen on Mac OSX using current finked python (2.3.3) but does appear to occur on Python 2.3.4 running on a very old Redhat Linux xxxxx 2.2.14-5.0 #1 Tue Mar 7 21:07:39 EST 2000 i686. The actual logged error follows my signature. Note that "files used:-" has been sent to the file. From a...
4
6123
by: Oz | last post by:
This is long. Bear with me, as I will really go through all the convoluted stuff that shows there is a problem with streams (at least when used to redirect stdout). The basic idea is that my application (VB.NET) will start a process, redirect its stdout and capture that process' output, displaying it in a window. I've written a component for this, and a test application for the component. It allows me to specify a command to execute,...
4
26922
by: Pascal Ehlert | last post by:
I don't know if this is the right newsgroup because the question is maybe a bit linux specific so if not slap me ;-) I'm trying to send the output of a perl-script to a socket. So I'm opening a pipe to the program (FILE fp = popen("foobar.pl", "r")) and read and write it directly to the socket.. This is my code: ------ while(!feof(fp)) { bytes = fread(b,1,1024,fp); fwrite(b,1,bytes,sock);
6
3065
by: Tim Chase | last post by:
While working on a Jumble-esque program, I was trying to get a string into a character array. Unfortunately, it seems to choke on the following import random s = "abcefg" random.shuffle(s) returning
2
1338
by: Robin Becker | last post by:
I'm using subprocess to carry out svn commands (probably should use the svn api package, but that's a dependency too far). Anyhow my code looks like from subprocess import Popen, PIPE p = Popen((svn,'ls',u),stdout=PIPE,stderr=PIPE) i = p.wait() and this sort of thing works well under most circumstances. However, when this code is executed for the very first time by a particular user it hangs waiting on user input.
1
2426
by: Christoph Krammer | last post by:
Hello everybody, I try to use an external OCR tool to convert some binary image data to text. The image is in one variable, the text should be converted to another. I use the following code: (si, so, se) = os.popen3('ocrad') si.write(frame) si.close() messagetext += so.read()
11
21631
by: 7stud | last post by:
Hi, Can someone explain what a broken pipe is? The following produces a broken pipe error: ---------- import subprocess as sub p = sub.Popen(, stdin=sub.PIPE, stdout=sub.PIPE)
0
10363
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10179
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11836
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11438
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10923
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7622
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6427
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4750
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3776
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.