1822158 Members
3544 Online
109640 Solutions
New Discussion юеВ

Re: Perl untie problem

 
SOLVED
Go to solution
Kalin Evtimov
Regular Advisor

Perl untie problem

Hi!
I just got an error from my perl-program, but since I have never used tie/untie, I don't know what to do first.

miniserv.pl: untie attempted while 1 inner references still exist at /opt/perl5/lib/5.8.6/IPC/Open3.pm line 203.

I looked at the line 203 and I found:

my $kid_rdr = gensym;
my $kid_wtr = gensym;
my $kid_err = gensym;

xpipe $kid_rdr, $dad_wtr if !$dup_wtr;
xpipe $dad_rdr, $kid_wtr if !$dup_rdr;
xpipe $dad_err, $kid_err if !$dup_err && $dad_err ne $dad_rdr;

$kidpid = $do_spawn ? -1 : xfork;
if ($kidpid == 0) { # Kid
# A tie in the parent should not be allowed to cause problems.
untie *STDIN;
untie *STDOUT; #this is line 203!!


Could anybody tell me how to find the variable, that is still tied? I couldn't find much bei Google...

Danke!
7 REPLIES 7
H.Merijn Brand (procura
Honored Contributor
Solution

Re: Perl untie problem

you probably need some close calls before the untie

close STDIN;
close STDOUT;
untie *STDIN;
untie *STDOUT;

And I don't know if the xpipe calls do other black magic;

Enjoy, Have FUN! H.Merijn

Enjoy, Have FUN! H.Merijn
Kalin Evtimov
Regular Advisor

Re: Perl untie problem

"And I don't know if the xpipe calls do other black magic;"

What do U mean?
This is actually the source of the IPC::Open3 module Open3.pm

close didn't work unfortunately.
Ralph Grothe
Honored Contributor

Re: Perl untie problem

Hm miniserv.pl sounds like a Webmin problem.
I wouldn't expect the IPC::Open3 module to be broken.
It rather looks that either a prerequisite isn't fulfilled, or it was used improperly.

Can you identify the line where your Perl code aborted?
Madness, thy name is system administration
Kalin Evtimov
Regular Advisor

Re: Perl untie problem

actually not, I have only the error msg. from above.
As I couldn't make RRDs module from RRDtool working on hp-ux, I rewrote my script for use with RRDp, and since than I get this errormsg. In the miniserv.pl there is a tie to STDIN and STDOUT,

eval {
package main;
tie(*STDOUT, 'miniserv');
tie(*STDIN, 'miniserv');
do $miniserv::full;
die $@ if ($@);
};

but I don't know how to find out what and where fails..
H.Merijn Brand (procura
Honored Contributor

Re: Perl untie problem

eval {
package main;
tie(*STDOUT, 'miniserv');
tie(*STDIN, 'miniserv');
do $miniserv::full;
untie *STDOUT; # <--
untie *STDIN; # <--
die $@ if ($@);
};

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
Kalin Evtimov
Regular Advisor

Re: Perl untie problem

No, ..:( this didn't work..I quess there must be a very special error that cannot be found out directly. Thank you for your help.
Ralph Grothe
Honored Contributor

Re: Perl untie problem

I haven't used tied file handles yet,
as you are.
I guess this is more for the advanced Perl hackers like procura.
So far I've only used tied hashes as they are used easiest of all.
As far as my memory serves me correctly one has to implement for each valid operation on the thingy (i.e. scalar, array, hash, filehandle, object reference) a method in order for tying to work.
Maybe you need to override the close method for the filehandle tie?

Have you consulted perldoc perltie yet?

You could also look at the code from your Perl installation to get an idea how implementation of tied variables works.
I'd say a pretty easy one to start with was Config.pm, though it's tying a hash rather than a file handle.
Anyway, have a look at "perldoc -m Config"
Madness, thy name is system administration