Question about pipes and exit codes

Jason Van Slyke jvanslyk at matchlogic.com
Wed Nov 17 10:12:56 CST 1999


Chip,

First up, you're way over my head.  But I found this interesting so I dug
out a couple, 3 or 4 books.

Do you have a Perl Cookbook available?  If so, see p567-571.

If not, this _might_ help:

eval {
	open2($readme, $writeme, @program_and_arguments) ;
} ;
if ($@) {
	if ($@ =~ /^open2/) {
		warn "open2 failed: $!\n$@\n" ;
		return ;
	}
	die ;		#reraise unforeseen exception
}

Let me know if this is playing in the same ball park as you are.

Jason

-----Original Message-----
From: William Atkinson [mailto:CWA at DISC.com]
Sent: Wednesday, November 17, 1999 8:46 AM
To: 'boulder-pm-list at pm.org'
Subject: Question about pipes and exit codes


Greetings,

Forgive and politely correct me if this is the wrong list to post to.

I'm having trouble getting the exit status of a process at the end of a pipe
created by open2.  It seems that all I get is notification that the pipe
broke.  

One idea that we came up with was to have a shell script run the desired
program, catch its exit status and return it as the last string.  The
problem with this is that I was hoping for a purely perl based solution due
to cross platform portability issues.

Any help would be appreciated.

Thanks.

Chip Atkinson
chip at disc.com



More information about the Boulder-pm mailing list