Closed p5pRT closed 21 years ago
seek() on a pipe should return an error\, but it doesn't
With ActivePerl 5.8\, this test program:
#!perl -w
# seektest.pl
while (\
when run as follows type testfile | perl seektest.pl
With testfile containing Line 1 Line 2 Line 3 Line 4 Line 5 Line 6
The output is (INCORRECT): Line 1 Line 2 Line 3 Seek succeeded END
When run with cygwin perl\, the output is (CORRECT): Line 1 Line 2 Line 3 Seek failed: Illegal seek Line 4 Line 5 Line 6 END
Ken Hirsch \perl5\-porters@​perl\.org writes:
# New Ticket Created by Ken Hirsch # Please include the string: [perl #22087] # in the subject line of all future correspondence about this issue. # \<URL: http://rt.perl.org/rt2/Ticket/Display.html?id=22087 >
This is a bug report for perl from kenhirsch@myself.com\, generated with the help of perlbug 1.34 running under perl v5.8.0.
----------------------------------------------------------------- [Please enter your report here] seek() on a pipe should return an error\,
Says who? ;-)
This probably _is_ a bug\, but if the file position is still in the buffer I think the run-time is a liberty to move it back and succeed.
I ask your reason because one of features of "sfio" I had considered copying for PerlIO was its ability to make any file-type "seekable" (which it does by creating a temp file containing an "image" of what is read/written to the stream).
but it doesn't
But does a subsequent read() return the original posn 0 data correctly?
With ActivePerl 5.8\, this test program: #!perl -w # seektest.pl while (\
) { print; if ($. == 3) { if (seek STDIN\, 0\, 0) { print "Seek succeeded\n"; } else { print "Seek failed: $!\n"; } } } print "END\n"; when run as follows type testfile | perl seektest.pl
With testfile containing Line 1 Line 2 Line 3 Line 4 Line 5 Line 6
The output is (INCORRECT): Line 1 Line 2 Line 3 Seek succeeded END
When run with cygwin perl\, the output is (CORRECT): Line 1 Line 2 Line 3 Seek failed: Illegal seek Line 4 Line 5 Line 6 END
[Please do not change anything below this line] ----------------------------------------------------------------- --- Flags: category=core severity=medium --- Site configuration information for perl v5.8.0:
Configured by ActiveState at Tue Feb 4 18:07:44 2003.
Summary of my perl5 (revision 5 version 8 subversion 0) configuration: Platform: osname=MSWin32\, osvers=4.0\, archname=MSWin32-x86-multi-thread uname='' config_args='undef' hint=recommended\, useposix=true\, d_sigaction=undef usethreads=undef 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='cl'\, ccflags ='-nologo -Gf -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCR YPT -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX' \, optimize='-MD -Zi -DNDEBUG -O1'\, cppflags='-DWIN32' ccversion=''\, gccversion=''\, gccosandvers='' intsize=4\, longsize=4\, ptrsize=4\, doublesize=8\, byteorder=1234 d_longlong=undef\, longlongsize=8\, d_longdbl=define\, longdblsize=10 ivtype='long'\, ivsize=4\, nvtype='double'\, nvsize=8\, Off_t='__int64'\, lseeksize=8 alignbytes=8\, prototype=define Linker and Libraries: ld='link'\, ldflags '-nologo -nodefaultlib -release -libpath:"C:\Perl\lib\CORE" -machine:x86' libpth="C:\Perl\lib\CORE" libs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib msvcrt.lib perllibs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib msvcrt.lib libc=msvcrt.lib\, so=dll\, useshrplib=yes\, libperl=perl58.lib gnulibc_version='undef' Dynamic Linking: dlsrc=dl_win32.xs\, dlext=dll\, d_dlsymun=undef\, ccdlflags=' ' cccdlflags=' '\, ddlflags='-dll -nologo -nodefaultlib -release -libpath:"C:\Perl\lib\CORE" -machine :x86'
Locally applied patches: ACTIVEPERL_LOCAL_PATCHES_ENTRY
--- @INC for perl v5.8.0: c:/Perl/lib c:/Perl/site/lib .
--- Environment for perl v5.8.0: CYGWIN=tty HOME=c:\home\Ken LANG (unset) LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset)
PATH=c:\perl\bin;c:\usr\local\bin;c:\\bin;c:\bin;c:\J2SDK_Forte\jdk1.4.0\bin;c:\Pyth on21\;c:\Perl\bin\;c:\bin;c:\vim\vim61;c:\WINDOWS\system32;c:\WINDOWS;c:\WINDOWS\Sys tem32\Wbem;c:\Program Files\Common Files\Adaptec Shared\System;c:\Program Files\Microsoft SDK\Bin\;c:\Program Files\Microsoft SDK\Bin\WinNT\;c:\Program Files\VSE\win;c:\Program Files\Microsoft Visual Studio\Common\Tools\WinNT;c:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin;c:\Program Files\Microsoft Visual Studio\Common\Tools;c:\Program Files\Microsoft Visual Studio\VC98\bin;c:\Program Files\Microsoft SDK\Bin\;c:\Program Files\Microsoft SDK\Bin\WinNT\;. PERL_BADLANG (unset) SHELL (unset) -- Nick Ing-Simmons http://www.ni-s.u-net.com/
From: "Nick Ing-Simmons (via RT)" \perlbug\-followup@​perl\.org
I ask your reason because one of features of "sfio" I had considered copying for PerlIO was its ability to make any file-type "seekable" (which it does by creating a temp file containing an "image" of what is read/written to the stream).
but it doesn't
But does a subsequent read() return the original posn 0 data correctly?
No\, it returns eof
This bug is due to Win32's lseek() not giving an error (or doing the right thing). It is fixed by fix to bugs 21717 and 22140 - which causes PerlIOUnix_seek to return error by itself if stream is not a "regular file".
nick@ing-simmons.net - Status changed from 'new' to 'resolved'
Migrated from rt.perl.org#22087 (status was 'resolved')
Searchable as RT22087$