True enough. I was only pointing out that there were system calls and didn't mean to suggest that any of those I mentioned were responsible for setting errno in this case or that it was an exhaustive list.

Investigating a little further, I find that several different versions of perl on my system (CentOS 5.3) produce the same result. Looking more closely at 5.10.1-RC1, it appears errno is being set to EBADF in PerlIO_fast_gets, with the following stack trace at the time:

#0 PerlIO_fast_gets (f=0x826cf88) at perlio.c:1790 #1 0x08120b86 in PerlIOBuf_fill (f=0x8264724) at perlio.c:3868 #2 0x0811f42e in PerlIOBase_read (f=0x8264724, vbuf=0xbfadde57, count +=1) at perlio.c:2143 #3 0x0811f550 in PerlIO_getc (f=0x8264724) at perlio.c:5066 #4 0x080d693a in Perl_sv_gets (sv=0x8269e10, fp=0x8264724, append=0) at sv.c:6852 #5 0x0807ff22 in Perl_filter_read (idx=0, buf_sv=0x8269e10, maxlen=0) at toke.c:2955 #6 0x08080124 in S_filter_gets (sv=0x8269e10, fp=0x8264724, append=13 +6761200) at toke.c:2997 #7 0x08084d7a in Perl_yylex () at toke.c:3757 #8 0x08092368 in Perl_yyparse () at perly.c:409 #9 0x080e9918 in S_doeval (gimme=0, startop=0x0, outside=0x0, seq=0) at pp_ctl.c:2981 #10 0x080eafeb in Perl_pp_require () at pp_ctl.c:3573 #11 0x080c053e in Perl_runops_standard () at run.c:40 #12 0x0806fede in Perl_call_sv (sv=0x8269d10, flags=6) at perl.c:2717 #13 0x0807023b in Perl_call_list (oldscope=2, paramList=0x8269db0) at perl.c:5264 #14 0x0805f3e8 in S_process_special_blocks (fullname=<value optimized +out>, gv=0x8269d90, cv=0x8269d10) at op.c:5860 #15 0x08068ec9 in Perl_newATTRSUB (floor=27, o=0x826cda0, proto=0x0, attrs=0x0, block=0x826cd60) at op.c:5831 #16 0x08067e00 in Perl_utilize (aver=1, floor=27, version=0x0, idop=0x +826cb70, arg=0x0) at op.c:3878 #17 0x080944dd in Perl_yyparse () at perly.y:659 #18 0x08071e0a in S_parse_body (env=0x0, xsinit=0x805e580 <xs_init>) at perl.c:2274 #19 0x08072ad7 in perl_parse (my_perl=0x8256008, xsinit=0x805e580 <xs_ +init>, argc=3, argv=0xbfae0c64, env=0x0) at perl.c:1687 #20 0x0805e52b in main (argc=3, argv=0xbfae0c64, env=0xbfae0c74) at perlmain.c:115

The function is:

int PerlIO_fast_gets(PerlIO *f) { if (PerlIOValid(f) && (PerlIOBase(f)->flags & PERLIO_F_FASTGETS)) +{ const PerlIO_funcs * const tab = PerlIOBase(f)->tab; if (tab) return (tab->Set_ptrcnt != NULL); SETERRNO(EINVAL, LIB_INVARG); } else SETERRNO(EBADF, SS_IVCHAN); return 0; }

So, system calls are not may not be the issue. It has may have something to do with Perl IO during require. It appears perl sets errno while reading strict.pm - based on observation of a successful read of the data a short time later. And I have no idea why it doesn't do the same when reading warnings.pm.

I note in passing that there are at least about 115 (give or take a few cpp conditionals and macros) places in the perl source where errno is set and about 54 places where errno is set to EBADF.

While I have found one place where errno is set to EBADF it is possibly not the last place where this value is set before the perl reads the value according to the print statement. Additional study would be required to confirm that this is the cause of $! being set when printed in the OP program.


In reply to Re^3: "use strict" sets $! by ig
in thread "use strict" sets $! by rovf

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.