This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Question on stdio standard behaviour (Bugreport libc/755)



Hi,

we've received the appended bugreport.  The essence is that "perl
expects that fclose followed by fopen will return the same pointer".
This works on most platforms but not with libc5 and glibc2.

So, my question is:  Is this assumption made by perl just an
assumption - or is it based on some standard which glibc2 violates?

Thanks,
Andreas
-- 
 Andreas Jaeger   aj@arthur.rhein-neckar.de    jaeger@informatik.uni-kl.de
  for pgp-key finger ajaeger@alma.student.uni-kl.de



>Number:         755
>Category:       libc
>Synopsis:       perl depends on fclose then fopen returning same pointer
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    libc-gnats
>State:          open
>Class:          sw-bug
>Submitter-Id:   unknown
>Arrival-Date:   Mon Aug 24 20:10:01 EDT 1998
>Last-Modified:
>Originator:     Chris Adams
>Organization:
  Chris Adams - cadams@ro.com
  System Administrator - Renaissance Internet Services
  I don't speak for anybody but myself - that's enough trouble.
>
>Release:        libc-2.0.7
>Environment:
	
Host type: i686-pc-linux-gnu
System: Linux sh1.ro.com 2.0.35 #3 Sat Jul 25 08:30:14 CDT 1998 i586 unknown
Architecture: i586

Addons: crypt linuxthreads localedata
Build CFLAGS: -O2 -m486 -fno-strength-reduce -g -DNDEBUG=1
Build CC: gcc -B$(common-objpfx)
Build shared: yes
Build profile: yes
Build omitfp: no
Stdio: libio

>Description:
I found what seems to be a bug in perl.  When I close and reopen STDERR
(to send it to a specific file or a pipe), the perl builtin "warn" and
"die" functions (that print a message to STDERR) don't display any
output or send it to the new STDERR.  I filed a bug report with the perl
developers, and someone said it is because perl expects that fclose
followed by fopen will return the same pointer.  I've never heard of
this behavoir before (I know that close then open returns the same
integer if all lower files are still open).

This happens under Linux with both libc5 and libc6, on x86 and alpha.
One person from the perl group said that the BSD and SysV library code
make sure that the pointer is the same when you fclose then fopen stdin.

>How-To-Repeat:
Here is the perl script:

#!/usr/bin/perl -w

open (NEWERR, ">&STDERR");
close (STDERR);
open (STDERR, ">&NEWERR");
close (NEWERR);
select (STDERR); $| = 1; select (STDOUT);
print STDERR "Hello\n";
warn "Test warn\n";
print STDERR "Bye\n";
die "Test die\n";

Under anything but Linux (I have tested WinNT, Digital Unix, AIX, and
others have tested Solaris and SunOS), this outputs:

Hello
Test warn
Bye
Test die

but under Linux, the Test warn and Test die lines aren't there.
>Fix:
I think this is probably a bad assumption in perl, but I guess there
could be other programs that make the same assumption about FILE *
pointers.
>Audit-Trail:
>Unformatted:




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]