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

open >&= works on RDONLY filehandle? #1010

Closed
p5pRT opened this issue Dec 30, 1999 · 3 comments
Closed

open >&= works on RDONLY filehandle? #1010

p5pRT opened this issue Dec 30, 1999 · 3 comments

Comments

@p5pRT
Copy link

p5pRT commented Dec 30, 1999

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

Searchable as RT1960$

@p5pRT
Copy link
Author

p5pRT commented Dec 30, 1999

From joseph@cscaper.com

use POSIX;
$fd = POSIX​::open("foo", O_RDONLY, 0644) or die $!;
open FH, ">&=$fd" or die $!;
print FH "here's something\n" or die $!;

Does it make sense that this yields no errors?

Perl Info


Site configuration information for perl 5.00502:

Configured by root at Thu Dec 31 02:40:42 MST 1998.

Summary of my perl5 (5.0 patchlevel 5 subversion 2) configuration:
  Platform:
    osname=solaris, osvers=2.7, archname=sun4-solaris
    uname='sunos rom 5.7 generic sun4u sparc sunw,ultrasparc-iii-engine '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
  Compiler:
    cc='gcc -B/usr/ccs/bin/', optimize='-O', gccversion=egcs-2.91.60 19981201 (egcs-1.1.1 release)
    cppflags='-I/usr/local/include'
    ccflags ='-I/usr/local/include'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lsocket -lnsl -lgdbm -ldl -lm -lc -lcrypt
    libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib'

Locally applied patches:
    


@INC for perl 5.00502:
    /usr/local/lib/perl5/5.00502/sun4-solaris
    /usr/local/lib/perl5/5.00502
    /usr/local/lib/perl5/site_perl/5.005/sun4-solaris
    /usr/local/lib/perl5/site_perl/5.005
    .


Environment for perl 5.00502:
    HOME=/home/joseph
    LANG (unset)
    LD_LIBRARY_PATH=/usr/lang/SC1.0.1:/usr/openwin/lib
    LOGDIR (unset)
    PATH=.:/usr/local/bin:/usr/ucb:/bin:/usr/bin:/usr/5bin:/etc:/usr/etc:/usr/lang:/usr/local/postgres95/bin:/usr/ccs/bin:/usr/sbin:/usr/X11/bin:/usr/openwin/bin:/usr/local/framemaker/bin:/usr/local/pbmplus/bin:/usr/local/games/bin
    PERL_BADLANG (unset)
    SHELL=/bin/tcsh

@p5pRT
Copy link
Author

p5pRT commented Jan 2, 2000

From @gsar

On 30 Dec 1999 23​:16​:23 GMT, joseph@​cscaper.com wrote​:

use POSIX;
$fd = POSIX​::open("foo", O_RDONLY, 0644) or die $!;
open FH, ">&=$fd" or die $!;
print FH "here's something\n" or die $!;

Does it make sense that this yields no errors?

This looks Solaris-specific. The fdopen() fails properly on Linux 2.0.36
with glibc.

Sarathy
gsar@​ActiveState.com

Site configuration information for perl 5.00502​:

Configured by root at Thu Dec 31 02​:40​:42 MST 1998.

Summary of my perl5 (5.0 patchlevel 5 subversion 2) configuration​:
Platform​:
osname=solaris, osvers=2.7, archname=sun4-solaris
uname='sunos rom 5.7 generic sun4u sparc sunw,ultrasparc-iii-engine '

@p5pRT
Copy link
Author

p5pRT commented Jan 2, 2000

From @ysth

In article <200001021725.JAA05334@​activestate.com>,
Gurusamy Sarathy <gsar@​ActiveState.com> wrote​:

On 30 Dec 1999 23​:16​:23 GMT, joseph@​cscaper.com wrote​:

use POSIX;
$fd = POSIX​::open("foo", O_RDONLY, 0644) or die $!;
open FH, ">&=$fd" or die $!;
print FH "here's something\n" or die $!;

Does it make sense that this yields no errors?

This looks Solaris-specific. The fdopen() fails properly on Linux 2.0.36
with glibc.

Under os2 it also doesn't give an error. However, adding a close FH
does get an EACCES error. Changing the print to​:

print FH 'x' x 10000 or die $!;

also gets an error.

It is not clear to me that the standards require fdopen to check this.
Perhaps it is simply left as undefined behaviour.

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