develooper Front page | perl.perl5.porters | Postings from January 2003

Re: [perl #20525] Perl's stdio layer doesn't handle EINTR

Thread Previous
From:
Nick Ing-Simmons
Date:
January 26, 2003 03:18
Subject:
Re: [perl #20525] Perl's stdio layer doesn't handle EINTR
Message ID:
20030126111640.1859.6@bactrian.ni-s.u-net.com
Mls@Suse.De <perl5-porters@perl.org> writes:
># New Ticket Created by  mls@suse.de 
># Please include the string:  [perl #20525]
># in the subject line of all future correspondence about this issue. 
># <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=20525 >
>
>
>
>This is a bug report for perl from mls@suse.de,
>generated with the help of perlbug 1.34 running under perl v5.8.0.
>
>
>-----------------------------------------------------------------
>[Please enter your report here]
>
>Perl's stdio IO layer doesn't restart the library calls if
>they return EINTR. Old perl versions aren't affected as they
>use SA_RESTART when they set up the signal handlers.

This is a side effect of the "safe signals" support.
I "had" to turn off SA_RESTART so that syscall would resturn and give us 
a chance to execute the perl level %SIG handler.
:perlio layer attempts to re-do (as opposed to re-start) the system call,
but I have not (yet?) tried that for :stdio as it is harder to 2nd-guess
the system's stdio as to where it has got to.

So using :perlio is a possible workround in short term.

A possible alternative to the above would be to have a global flag 
which gets set just before we start a syscall to say calling %SIG handler
is okay (as we are in a syscall not malloc or perl code) and re-instate
SA_RESTART. The snag is that un-setting the flag is a potential race.
must cope with die and needs splattering all over the C code.
Potentially we can use PerlSIO_xxx/PerlLIO_xxx wrappers to do this.



>
>Test program:
>
>use POSIX;
>
>$SIG{CHLD} = sub {};
>
>if (fork() == 0) {
>  $ppid = getppid;
>  while (1) {
>    exit if kill(POSIX::SIGCHLD, $ppid) != 1;
>  }
>}
>$cnt = 0;
>open(F, "cat /etc/termcap|") || die "open\n";
>$cnt++ while <F>;
>close F;
>print "-> $cnt\n";
>
>The test program often returns zero read lines (GNU glibc). Adding
>    binmode F, ":unix"
>fixes this, of course.
>
>[Please do not change anything below this line]
>-----------------------------------------------------------------
>---
>Flags:
>    category=core
>    severity=medium
>---
>This perlbug was built using Perl v5.8.0 - Mon Sep  9 18:12:37 UTC 2002
>It is being executed now by  Perl v5.8.0 - Mon Sep  9 18:02:36 UTC 2002.
>
>Site configuration information for perl v5.8.0:
>
>Configured by root at Mon Sep  9 18:02:36 UTC 2002.
>
>Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
>  Platform:
>    osname=linux, osvers=2.4.19, archname=i586-linux-thread-multi
>    uname='linux bloembergen 2.4.19 #1 mon apr 15 08:57:26 gmt 2002 i686 unknown '
>    config_args='-ds -e -Dprefix=/usr -Dusethreads -Di_db -Di_dbm -Di_ndbm -Di_gdbm -Duseshrplib=true'
>    hint=recommended, useposix=true, d_sigaction=define
>    usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
>    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
>    use64bitint=undef use64bitall=undef uselongdouble=undef
>    usemymalloc=n, bincompat5005=undef
>  Compiler:
>    cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
>    optimize='-O3 --pipe',
>    cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing'
>    ccversion='', gccversion='3.2', gccosandvers=''
>    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
>    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
>    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
>    alignbytes=4, prototype=define
>  Linker and Libraries:
>    ld='cc', ldflags =''
>    libpth=/lib /usr/lib /usr/local/lib
>    libs=-lnsl -ldl -lm -lpthread -lc -lcrypt -lutil
>    perllibs=-lnsl -ldl -lm -lpthread -lc -lcrypt -lutil
>    libc=, so=so, useshrplib=true, libperl=libperl.so
>    gnulibc_version='2.2.5'
>  Dynamic Linking:
>    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic -Wl,-rpath,/usr/lib/perl5/5.8.0/i586-linux-thread-multi/CORE'
>    cccdlflags='-fPIC', lddlflags='-shared'
>
>Locally applied patches:
>    
>
>---
>@INC for perl v5.8.0:
>    /usr/lib/perl5/5.8.0/i586-linux-thread-multi
>    /usr/lib/perl5/5.8.0
>    /usr/lib/perl5/site_perl/5.8.0/i586-linux-thread-multi
>    /usr/lib/perl5/site_perl/5.8.0
>    /usr/lib/perl5/site_perl
>    .
>
>---
>Environment for perl v5.8.0:
>    HOME=/suse/mls
>    LANG (unset)
>    LANGUAGE (unset)
>    LC_COLLATE=POSIX
>    LC_CTYPE=de_DE@euro
>    LD_LIBRARY_PATH (unset)
>    LOGDIR (unset)
>    PATH=/suse/mls/bin:/opt/kde3/bin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/bin:/usr/lib/java/bin:/usr/games/bin:/usr/games:/opt/gnome/bin:/opt/kde/bin:/usr/openwin/bin:/opt/pilotsdk/bin:/suse/mls/korn
>    PERL_BADLANG (unset)
>    SHELL=/bin/tcsh
-- 
Nick Ing-Simmons
http://www.ni-s.u-net.com/


Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About