Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linix, Open2() and DEFUNCT processes. #1382

Closed
p5pRT opened this issue Mar 18, 2000 · 4 comments
Closed

Linix, Open2() and DEFUNCT processes. #1382

p5pRT opened this issue Mar 18, 2000 · 4 comments

Comments

@p5pRT
Copy link

p5pRT commented Mar 18, 2000

Migrated from rt.perl.org#2462 (status was 'resolved')

Searchable as RT2462$

@p5pRT
Copy link
Author

p5pRT commented Mar 18, 2000

From Dan_Needles@ins.com

Hello,
  I'm trying to find out if there is an existing problem with defunct
processes using Open2() on Linux.

I have a loop that repeatively calls Open2() against a process that
takes a block of standard in, processes it and writes it to standard out

before the loop starts again. The output is always correct but the
called process remains in DEFUNCT state until I kill the Open2() calling

program. Worse, I cannot kill the DEFUNCT processes. Only by killing
the PERL program will they go away.

Any ideas? Do you know of any EMAIL LISTS that could address this?

Thanks,
Daniel L. Needles

@p5pRT
Copy link
Author

p5pRT commented Mar 18, 2000

From [Unknown Contact. See original ticket]

Did you close the file handles?
Did you wait on your forked children?

--tom

@p5pRT
Copy link
Author

p5pRT commented Mar 18, 2000

From [Unknown Contact. See original ticket]

Message RFC822:
X-Mozilla-Status2: 00000000
Message-ID: 38D45EEA.178B524F@ins.com
Date: Sat, 18 Mar 2000 21:00:26 -0800
From: "Daniel L. Needles" Dan_Needles@ins.com
Organization: International Network Services
X-Mailer: Mozilla 4.61 [en] (Win98; I)
X-Accept-Language: en
MIME-Version: 1.0
To: Tom Christiansen tchrist@chthon.perl.com
Subject: Re: [ID 20000318.005] Linix, Open2() and DEFUNCT processes.
References: 25181.953439599@chthon
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Tom Christiansen wrote:

Did you close the file handles?

Yes

Did you wait on your forked children?

Not sure. Could you check the 20 line program that follows:

#!/opt/CAV1perl/bin/perl
################################################################################

PROGRAM: OPEN2TEST Version 1.0 Daniel L.

Needles #
################################################################################

LOAD MODULES

use FileHandle; # For Open2 (Default PERL has no bidirectional pipes.)
use IPC::Open2; # For Open2 (Default PERL has no bidirectional pipes.)

PREPARE ENVIRONMENT

my $ip, $ms, $icmptype, $icmpcode, $responder, $junk;
my ($FIN, $FOUT) = (FileHandle->new, FileHandle->new);
open(DEBUG, '> async.out') or die "ASYNC: E: Could not open debug
file.\n";

while ( 1 ) {
$fping = open2( $FOUT, $FIN, "./f -e" ) || die "ASYNC: Could not open
bidirect
ional pipe.";

INPUT DATA

$wtcnt=0;
print $FIN "127.0.0.1\n";
print $FIN "127.0.0.1\n";
print $FIN "127.0.0.1\n";

SIGNAL TIME FOR OUTPUT

print $FIN "-\n";
close($FIN);

RECEIVE DATA

while ( $data = <$FOUT> ) {
if ($data ne "" ) {
( $ip, $ms, $icmptype, $icmpcode, $responder, $junk ) = split
/,/,$data,6;
chomp($responder);

}

}
close($FOUT);
sleep 60;
}

--tom

@p5pRT
Copy link
Author

p5pRT commented Mar 18, 2000

From [Unknown Contact. See original ticket]

Russ,
  Thanks! That was it! Adding waitpid($f, 0); after the last close did the trick!

Thanks,
Daniel L. Needles

"Daniel L. Needles" wrote​:

------------------------------------------------------------------------

Subject​: Re​: [ID 20000318.005] Linix, Open2() and DEFUNCT processes.
Date​: Sat, 18 Mar 2000 21​:00​:26 -0800
From​: "Daniel L. Needles" <Dan_Needles@​ins.com>
Organization​: International Network Services
To​: Tom Christiansen <tchrist@​chthon.perl.com>
References​: <25181.953439599@​chthon>

Tom Christiansen wrote​:

Did you close the file handles?

Yes

Did you wait on your forked children?

Not sure. Could you check the 20 line program that follows​:

#!/opt/CAV1perl/bin/perl
################################################################################

# PROGRAM​: OPEN2TEST Version 1.0 Daniel L.
Needles #
################################################################################

# LOAD MODULES
use FileHandle; # For Open2 (Default PERL has no bidirectional pipes.)
use IPC​::Open2; # For Open2 (Default PERL has no bidirectional pipes.)

# PREPARE ENVIRONMENT
my $ip, $ms, $icmptype, $icmpcode, $responder, $junk;
my ($FIN, $FOUT) = (FileHandle->new, FileHandle->new);
open(DEBUG, '> async.out') or die "ASYNC​: E​: Could not open debug
file.\n";

while ( 1 ) {
$fping = open2( $FOUT, $FIN, "./f -e" ) || die "ASYNC​: Could not open
bidirect
ional pipe.";

# INPUT DATA
$wtcnt=0;
print $FIN "127.0.0.1\n";
print $FIN "127.0.0.1\n";
print $FIN "127.0.0.1\n";
# SIGNAL TIME FOR OUTPUT
print $FIN "-\n";
close($FIN);

# RECEIVE DATA
while ( $data = <$FOUT> ) {
if ($data ne "" ) {
( $ip, $ms, $icmptype, $icmpcode, $responder, $junk ) = split
/,/,$data,6;
chomp($responder);

\}

}
close($FOUT);
sleep 60;
}

--tom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant