472,995 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,995 software developers and data experts.

writing to a pipe on win32

Hi experts,
I need to write a perl script that will be called from a series of
executables chained thru pipes that read from STDIN and writes to
STDOUT. The following code works fine under regular circumstance. But
when there is a error down the pipe in one of the executables, the
pipe closes and then this script just exits. It does not print line
14. The troublesome line is line number 17. If I comment it out, the
script completes. From my very little perl knowledge, I was thinking
that in line 17, when we call "print $_" and the pipe broke due to the
error in another executable, it would generate SIGPIPE, but I get no
signal. Does SIGPIPE work on windows ?

1 sub signalhandler
2 {
3 print STDERR "*Received a SIG$_[0]\n";
4 }

5 my $Tmp_File = "c:/test_dir/testFile";

6 open(IN_FILE, ">$Tmp_File") || die "Open file error: $!";
7 binmode (IN_FILE);

8 while (<STDIN>) {
9 print IN_FILE ;
10 }
11 close(IN_FILE);

12 use sigtrap qw{handler signalhandler normal-signals
error-signals};

13 open(OUT_FILE, "$some_other_executable $Tmp_File |") || die
"Fork error: $!";
14 print STDERR "Opened file OUT_FILE!!\n";
15 binmode (OUT_FILE);
16 while (<OUT_FILE>) {
17 print $_;
18 }
19 unlink ($Tmp_File) || die "Remove file error: $!";

Thanks in advance.

Momena
Jul 19 '05 #1
1 5160
mo*****@yahoo.com (momena) wrote in message news:<1a**************************@posting.google. com>...
Hi experts,
I need to write a perl script that will be called from a series of
executables chained thru pipes that read from STDIN and writes to
STDOUT. The following code works fine under regular circumstance. But
when there is a error down the pipe in one of the executables, the
pipe closes and then this script just exits. It does not print line
14. The troublesome line is line number 17. If I comment it out, the
script completes. From my very little perl knowledge, I was thinking
that in line 17, when we call "print $_" and the pipe broke due to the
error in another executable, it would generate SIGPIPE, but I get no
signal. Does SIGPIPE work on windows ?

1 sub signalhandler
2 {
3 print STDERR "*Received a SIG$_[0]\n";
4 }

5 my $Tmp_File = "c:/test_dir/testFile";

6 open(IN_FILE, ">$Tmp_File") || die "Open file error: $!";
7 binmode (IN_FILE);

8 while (<STDIN>) {
9 print IN_FILE ;
10 }
11 close(IN_FILE);

12 use sigtrap qw{handler signalhandler normal-signals
error-signals};

13 open(OUT_FILE, "$some_other_executable $Tmp_File |") || die
"Fork error: $!";
14 print STDERR "Opened file OUT_FILE!!\n";
15 binmode (OUT_FILE);
16 while (<OUT_FILE>) {
17 print $_;
18 }
19 unlink ($Tmp_File) || die "Remove file error: $!";

Thanks in advance.

Momena


I ran it on unix (hpux) and I get SIGTERM, not SIGPIPE. Now that I
think about it again, it makes sense not to get a SIGPIPE, because I
am not directly writing to a pipe in line 17, even though other end os
STDOUT is a pipe. But in windows I get no signals. It seems very wrong
to me. Any comments ?
Jul 19 '05 #2

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

Similar topics

8
by: Deepa | last post by:
I am writing a console app in c# wherein am converting a dataset into a CSV file. It works fine. But I have some values in the dataset which have a comma within(eg. A,B,C). When I view the CSV file...
13
by: j. del | last post by:
I am just beginning to write programs... and my first task that I have set myself is to write a little program that will generate cryptic bywords from a source of text. A cryptic byword is...
6
by: Carson | last post by:
Hi, How to write c code such that it supports pipe in? i.e., echo "ABCD" | a.out (how to write a c-code which generates the binaries a.out that can take the pipe in input for further...
8
by: mojozoox | last post by:
Could you tell me scenarios in which core's dumped when writing to a pipe. write (pipefd,&Struct,structsize); on windows too this give a memory "read" violation. Could anyone tell me why. ...
3
by: EricR | last post by:
I am trying to use .NET to "tap into" a named pipe created by a non .NET 3rd party application. Specifically, the application is a table loading utility. It opens a named pipe and waits for input....
6
by: placid | last post by:
Hi all, I have been looking into non-blocking read (readline) operations on PIPES on windows XP and there seems to be no way of doing this. Ive read that you could use a Thread to read from the...
4
by: Gigs_ | last post by:
does anyone know some good tutorial on pipes in python? thx
2
by: MAx | last post by:
Hi guys, I am a c++ newbee and i am trying to write a file to a default printer. Please have a look at the code below and let me know if it'll work. I know that similar code in C will work. I...
1
by: sven _ | last post by:
Keywords: subprocess stdout stderr unbuffered pty tty pexpect flush setvbuf I'm trying to find a solution to <URL:http://bugs.python.org/issue1241>. In short: unless specifically told not to,...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.