[ID 19991005.002] bug with die under linux

  Hi,

  It looks there's a bug with die under linux. It can be evidenced with the following
code:
=============================================================================
#!/usr/bin/perl

# save STDERR and redirect to /dev/null
open OLDSTDERR, ">&STDERR" or die "STDERR dup failed: $!";
close STDERR;
open STDERR, ">/dev/null" or die "STDERR redirect failed: $!";

# restore previous state

close STDERR;
open STDERR, ">&OLDSTDERR" or die "STDERR restoration failed: $!";
close OLDSTDERR;

print STDERR "this is printed correctly\n";

die "this message is not printed under linux\n";
=====================================================================

  The bug is that the die message is not displayed.

  The bug appears on every perl 5.00X on linux. It was tested with the out of the box perl
from Slackware,Debian 2.1, redhat, suse, and mandrake , and also on  a perl 5.005_03 and
5.004_04 which I compiled on my debian 2.1 box. It seems to work with every other flavours
of unix.

  However the message is displayed correctly if both "close STDERR;" instructions are
removed. (if they are removed, I've been told the dup doesn't work under NT)


0
richard
10/5/1999 2:07:25 PM
perl.perl5.porters 48206 articles. 1 followers. Follow

4 Replies
275 Views

Similar Articles

[PageSpeed] 55

On 05 Oct 1999 14:07:25 -0000, we-will-never-know-who wrote:
>  It looks there's a bug with die under linux. It can be evidenced with the following
>code:
>=============================================================================
>#!/usr/bin/perl
>
># save STDERR and redirect to /dev/null
>open OLDSTDERR, ">&STDERR" or die "STDERR dup failed: $!";
>close STDERR;
>open STDERR, ">/dev/null" or die "STDERR redirect failed: $!";
>
># restore previous state
>
>close STDERR;
>open STDERR, ">&OLDSTDERR" or die "STDERR restoration failed: $!";
>close OLDSTDERR;
>
>print STDERR "this is printed correctly\n";
>
>die "this message is not printed under linux\n";
>=====================================================================
>
>  The bug is that the die message is not displayed.
>
>  The bug appears on every perl 5.00X on linux. It was tested with the out of the box pe
>rl
>from Slackware,Debian 2.1, redhat, suse, and mandrake , and also on  a perl 5.005_03 and
>5.004_04 which I compiled on my debian 2.1 box. It seems to work with every other flavou
>rs
>of unix.
>
>  However the message is displayed correctly if both "close STDERR;" instructions are
>removed. (if they are removed, I've been told the dup doesn't work under NT)

This appears to be a peculiarity of libc/glibc on Linux.

I'm sure if I'd go so far as to call it a bug in libc, though.  FWIW,
here's a simple test case:

    #include <stdio.h>

    int
    main(int argc, char **argv)
    {
	FILE *oldstderr, *newstderr;
	printf("stderr=%d\n", fileno(stderr));

	oldstderr = fdopen(dup(fileno(stderr)), "w");
	printf("oldstderr=%d\n", fileno(oldstderr));
	fclose(stderr);

	newstderr = fdopen(dup(fileno(oldstderr)), "w");
	printf("newstderr=%d\n", fileno(newstderr));
	printf("stderr=%d\n", fileno(stderr));
	fclose(oldstderr);

	fprintf(stderr, "works\n");
	return 0;
    }

On a stock Debian Linux 2.1 system (with glib-2.0.7 I think), it prints:

    stderr=2
    oldstderr=3
    newstderr=2
    stderr=-1

On Solaris 2.6 (and a few other platforms), it prints:

    stderr=2
    oldstderr=3
    newstderr=2
    stderr=2
    works

Perl itself has been fixed to not rely on the behavior above.  See:
ftp://ftp.linux.activestate.com/pub/staff/gsar/APC/5.005_62/diffs/5302.gz


Sarathy
gsar@activestate.com
0
gsar
10/6/1999 3:01:39 AM
On Tue, 05 Oct 1999 20:01:39 PDT, Gurusamy Sarathy wrote:
>I'm sure if I'd go so far as to call it a bug in libc, though.  [...]
    ^
    ^
    *not*


Sarathy
gsar@activestate.com
0
gsar
10/6/1999 3:03:54 AM
Guru Sarathy was said to have uddered:
> Perl itself has been fixed to not rely on the behavior above.  See:
> ftp://ftp.linux.activestate.com/pub/staff/gsar/APC/5.005_62/diffs/5302.gz

Did you mean 4302.gz?

PS  I confirm the glibc2 issue with glib-2.1.2 (Debian Linux Potato)

-- 

Michael G Schwern                                           schwern@pobox.com
                    http://www.pobox.com/~schwern
     /(?:(?:(1)[.-]?)?\(?(\d{3})\)?[.-]?)?(\d{3})[.-]?(\d{4})(x\d+)?/i
0
schwern
10/6/1999 7:20:00 PM
Gurusamy Sarathy <gsar@activestate.com> writes:

> This appears to be a peculiarity of libc/glibc on Linux.
> 
> I'm sure if I'd go so far as to call it a bug in libc, though.  FWIW,
> here's a simple test case:

This is definitely no bug.  Rather, other systems are borken if they
allow writing to a stream which previously was closed.

-- 
---------------.      drepper at gnu.org  ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Cygnus Solutions `--' drepper at cygnus.com   `------------------------
0
drepper
10/11/1999 3:27:36 AM
Reply:

Similar Artilces:

[ID 19991117.002] a bug in perl5 under Linux
I find this problem when I use perl5 compiled under Linux. % perl -v This is perl, version 5.005_03 built for i386-linux % perl print 8473018401 % 524288 , "\n" 524287 The correct answer should be 33. Guoheng Wei _.-. Sr. Component Design Eng. '( ^{_} ( Intel Corp. `~\`-----'\ 512-314-0053 )_)---)_) >I find this problem when I use perl5 compiled under Linux. >% perl -v >This is perl, version 5.005_03 built for i386-linux >% perl >print 8473018401 ...

[ID 20001202.002] [BUG all] 'die qr{pattern}' does not check termination
With 5.6.0 for example: crypt% perl -we 'die qr{x}' (?-xism:x)crypt% should be the same as: crypt% perl -we 'die "(?-xism:x)"' (?-xism:x) at -e line 1. crypt% Hugo --- Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration: Platform: osname=linux, osvers=2.2.5-16, archname=i686-linux uname='linux crypt.compulink.co.uk 2.2.5-16 #1 sun may 30 23:00:18 bst 1999 i686 unknown ' config_args='-des -Doptimize=-g -O6 -Dprefix=/opt/perl-5.6.0' hint=recommended, useposix=true, d_sigaction=define ...

[ID 20010519.002] Bug report: warn/die with null car doesn't outputs all its content
Hi there, Here is a bug (or a feature that is not documented...) within the warn and the die functions: when you call them with a string or a list having a null car in it, the output does _not_ get further than this car. Here is a very simple test case: -- BEGIN OF TEST CASE $ perl -e '$a="foo".chr(0)."bar"; warn $a;' foo at -e line 1. $ perl -e '@a=("foo", chr(0), "bar"); warn @a;' foo at -e line 1. $ perl -e '$a="foo".chr(0)."bar"; die $a;' foo at -e line 1. $ perl -e '@a=("foo"...

[ID 19991216.002] do-while bug
I did a quick search of the PerlBug Database, but I didn't find anything that seems related. I found a bug, or at least unexpected operation, from the last operator inside a do-while loop. % perl -v This is perl, version 5.005_03 built for i386-linux Copyright 1987-1999, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5.0 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using `man perl' or `perldoc perl'. If y...

[ID 20010821.002] bug in getpwnam
This is a bug report for perl from carsten.grohmann@dr-baldeweg.de, generated with the help of perlbug 1.28 running under perl v5.6.0. ----------------------------------------------------------------- I want to change the owner of a file by using the following command: chown (getpwnam ($username))[2], (getgrnam ($groupname))[2], $destfile; and I get an syntax error near )[. After I replace the getpwnam call by a sub which uses the same expression, it works fine. The function getgrnam works in the same context without problems. Two smilar functions one runs the other not - is...

[Fwd: Bug ID 20010311.002]
Mathew, No Probs. Just mail to p5p with the bugid in the subject, and it will be tracked. I've forwarded this one for you. Ciao Richard -------- Original Message -------- Subject: Bug ID 20010311.002 Date: Mon, 12 Mar 2001 22:10:01 -0500 From: "Matthew O. Persico" <persicom@acedsl.com> To: richard@rfi.net I couldn't figure out how to post a folowup on the perlbug site. Sorry for the personal mail. I uninstalled the VC++5.0 SP3 compiler and re-installed just the base, no service pack. There were no problems with compilation. Seems like...

[ID 19991210.002] installation bug
Hi! I am trying to install perl on a sparc 10 with Solaris 2.6 I use " sh Configure -Dcc=gcc -des " It repeats the following infinitely current working directory /kumudu/lan/app/pkg/prl/perl5.005_03 /bin/sh Makefile.SH Extracting Makefile (with variable substitutions) make depend MAKEDEPEND= sh ./makedepend MAKE=make Please help me to sort this out. Thanks KUMUDU ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com Kumudu Suriyaarachchi writes: > > Hi! > I am trying to install perl on a...

[ID 20000719.002] Require Bug?
I have been trying to add Perl CGI to my web site. I'm running: Mandrake Linux with Perl 5.005_03 When using the perl command require to include a file, the variables assigned in an array do not always become available to the file using the require. Just keep clicking on reload or refresh in your browser and watch the values change. I used: Netscape 4.72 and Explorer 4.0 an example is at http://www.mhiconn.net/perl/requiretest/requiretest.pl and the files used are at: http://www.mhiconn.net/perl/requiretest/ Please Help...thanks Bruce Chidester ___________...

[ID 20000918.002] bug in bugtron
This is a bug report for perl from michael@etla.org, generated with the help of perlbug 1.20 running under perl 5.00404. ----------------------------------------------------------------- [Please enter your report here] The perl bugtron contains a bug at the following url: http://bugs.perl.org/admin/perlbug.cgi?req=bid&bid=19990805.004&bid=19990807.006&bid=19990809.001&bid=19990809.007&bid=19990809.008&bid=19990810.001&bid=19990811.004&bid=19990818.003&bid=19990820.001&bid=19990820.003&bid=19990820.006&bid=19990820.008&bid=19990...

[ID 20011203.002] Bug Report
--Boundary_(ID_o5KxOHjeze4zagdNwe5gxg) Content-type: MULTIPART/ALTERNATIVE; BOUNDARY="Boundary_(ID_TgNKl9JjPO2vSYjIsmKSGg)" --Boundary_(ID_TgNKl9JjPO2vSYjIsmKSGg) Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT This is a bug report for perl from jeremie.banier@swift.com, generated with the help of perlbug 1.26 running under perl 5.00503. ----------------------------------------------------------------- [Please enter your report here] As I try to compile a very simple test program, I get a Parsing Exception. Here's the code causi...

Problem with webservice method Bug.comment for "ids" set as bug ids
Hi, I need to access Bugzilla (Version of Bugzilla used bugzilla 4.0rc) webservice interface from a Java application. I have written a webservice client with Apache XML RPC. To fetch a comment for bug, I am using the following code : Map paramMap = new HashMap(); paramMap.put("ids", comments); //where comments is String[] of bug ids ArrayList<Object> paramBug = new ArrayList<Object>(); paramBug.add(paramMap); HashMap result = (HashMap) rpcClient.execute("Bug.comments", paramBug); Web service call returns an empty HashMap, with no comments....

[ID 20020407.002] Bug (?) and patch for DProf
This is a bug report for perl from tom@thecap.org, generated with the help of perlbug 1.33 running under perl v5.6.1. ----------------------------------------------------------------- I tried running the following script: #!/usr/bin/perl use strict; use LWP::UserAgent; use HTTP::Request; my $ua = LWP::UserAgent->new(); my $req = HTTP::Request->new('GET', 'http://www.google.com/'); my $res = $ua->simple_request( $req ); print "Response is: '".substr($res->as_string(),0,100)."'\n"; print "Context is: "; ...

[ID 20001130.002] a new test bug
message body with perl mentioned category=core should keep 'xxxyz@here.and.gone.today' as Message-Id remap to perl5-porters@perl.org subject should get [ID ...] with an ack=no somewhere ?-) X-Header: should be maintained etc. --- sig ...

[ID 20010521.002] die() a NOP after require()
This is a bug report for perl from ilya@math.ohio-state.edu, generated with the help of perlbug 1.33 running under perl v5.6.1. Ouph, this one took many hours to diagnose... Here is the scoop: In many situations doing die() after a require() is a kinda no-op. Currently I can reproduce only one such situation: perl_call_*() without G_EVAL called inside eval {}, but I believe many other contexts behave similarly. Details of the control flow with the bug present: perl_call_*() does not return (!), but the Perl control is quietly (without longjmp()ing out of perl_...

Web resources about - [ID 19991005.002] bug with die under linux - perl.perl5.porters

President Obama to Deliver Address on Terrorism Sunday
President Obama will deliver a primetime address to the nation Sunday night on the threat of terrorism, the White House said, following last ...

Watch: New 'The Force Awakens' Featurette on the Star Wars Legacy
"What happens to these characters we know and love - it's a world I want to get back to immediately." Lucasfilm has unveiled another new featurette ...

Aquarium artwork brings home the threat of climate change
As world leaders and scientists wrestled this week over how to respond to climate change at the U.N. Climate Summit in Paris, locals and passersby ...

Tallahassee Police Finally Admit Problems With Investigation Of Jameis Winston Rape Case
One of the most sinister things that came to light in the Jameis Winston case was how Florida State and local police protected athletes accused ...

Kim Kardashian And Kanye West’s Baby Boy Name? Baby Named After Kim’s Late Father, Says Report
The speculation of the name of the baby boy born to Kim Kardashian-West and Kanye West has hit an all-time high now that Kim delivered a baby ...

Psychonauts in the Rhombus of Ruin Revealed for PlayStation VR
It seems like just the other day we were announcing a new Psychonauts game , and now we’re announcing another! What is this, Christmas time? ...

Armed Bank Robber Shot, Killed in Miami Beach
The suspect had a straight edge razor in his hand, police said.

Donald Trump Repeatedly Interrupted During Rally, Supporters Boo And Attack Protesters
Donald Trump was repeatedly interrupted during his speech at a rally in Raleigh, North Carolina on Friday. WNCN had reported on Thursday that ...

Boko Haram Koulfoua, Lake Chad Island Suicide Bombing: 15 Victims Reported Dead
Up to 15 people have been killed in attacks by three suicide bombers on Koulfoua, an island in Lake Chad according to RT . Yahoo! News is reporting ...

NASA shows the sharpest ever close-up photos of Pluto
I can practically hear you groan more Pluto photos? Well, these are kind of special: they're the sharpest pictures the New Horizons probe took ...

Resources last updated: 12/6/2015 2:28:46 AM