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

File::Find: account for WSL; tidy assignment to dont_use_nlink #15748

Closed
p5pRT opened this issue Dec 4, 2016 · 16 comments
Closed

File::Find: account for WSL; tidy assignment to dont_use_nlink #15748

p5pRT opened this issue Dec 4, 2016 · 16 comments

Comments

@p5pRT
Copy link

p5pRT commented Dec 4, 2016

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

Searchable as RT130258$

@p5pRT
Copy link
Author

p5pRT commented Dec 4, 2016

From @jkeenan

Created by @jkeenan

This RT incorporates and builds upon discussion initiated by Thorsten
Behrens on the perl5-porters mailing list in a thread starting at​:
http​://www.nntp.perl.org/group/perl.perl5.porters/2016/12/msg241336.html.

Thorsten wrote​:

"As per discussion here
microsoft/WSL#186, WSL confuses
File​::Find. WSL is the "Windows Subsystem for Linux", which runs Ubuntu
on top of Windows 10.

"File​::Find sees that $^O is 'linux' and uses nlink, which doesn't work.
After some discussion, this code added to Find.pm special-cases for WSL
and solves the issue[.]"

Discussion on the mailing list included feedback on the code from Uri
Guttman. When I inspected the parts of File​::Find which would be
patched, I realized that the way in which $File​::Find​::dont_use_nlink
was being assigned could do with some tidying. The patch attached takes
Thorsten's approach to resolving the WSL issue and reflects Uri's
suggestions.

Please review.

(As we gain experience with WSL, we should in the future consider
checking for it in Configure. But let's deal with the presenting
problem first.)

Thank you very much.

Jim Keenan

Perl Info

Flags:
     category=library
     severity=low
     module=File::Find

Site configuration information for perl 5.24.0:

Configured by jkeenan at Mon May  9 18:37:23 EDT 2016.

Summary of my perl5 (revision 5 version 24 subversion 0) configuration:

   Platform:
     osname=linux, osvers=3.13.0-85-generic, archname=x86_64-linux
     uname='linux zareason 3.13.0-85-generic #129-ubuntu smp thu mar 17 
20:50:15 utc 2016 x86_64 x86_64 x86_64 gnulinux '
     config_args='-de 
-Dprefix=/home/jkeenan/perl5/perlbrew/perls/perl-5.24.0 
-Aeval:scriptdir=/home/jkeenan/perl5/perlbrew/perls/perl-5.24.0/bin'
     hint=recommended, useposix=true, d_sigaction=define
     useithreads=undef, usemultiplicity=undef
     use64bitint=define, use64bitall=define, uselongdouble=undef
     usemymalloc=n, bincompat5005=undef
   Compiler:
     cc='cc', ccflags ='-fwrapv -fno-strict-aliasing -pipe 
-fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE 
-D_FILE_OFFSET_BITS=64',
     optimize='-O2',
     cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector 
-I/usr/local/include'
     ccversion='', gccversion='4.8.4', gccosandvers=''
     intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678, 
doublekind=3
     d_longlong=define, longlongsize=8, d_longdbl=define, 
longdblsize=16, longdblkind=3
     ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', 
lseeksize=8
     alignbytes=8, prototype=define
   Linker and Libraries:
     ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
     libpth=/usr/local/lib 
/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed 
/usr/include/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib/../lib 
/usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib /lib64 /usr/lib64
     libs=-lpthread -lnsl -ldb -ldl -lm -lcrypt -lutil -lc
     perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
     libc=libc-2.19.so, so=so, useshrplib=false, libperl=libperl.a
     gnulibc_version='2.19'
   Dynamic Linking:
     dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
     cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib 
-fstack-protector'



@INC for perl 5.24.0:
 
/home/jkeenan/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0/x86_64-linux
     /home/jkeenan/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0
     /home/jkeenan/perl5/perlbrew/perls/perl-5.24.0/lib/5.24.0/x86_64-linux
     /home/jkeenan/perl5/perlbrew/perls/perl-5.24.0/lib/5.24.0
     .


Environment for perl 5.24.0:
     HOME=/home/jkeenan
     LANG=en_US.utf-8
     LANGUAGE=en_US
     LD_LIBRARY_PATH (unset)
     LOGDIR (unset)
 
PATH=/home/jkeenan/perl5/perlbrew/bin:/home/jkeenan/perl5/perlbrew/perls/perl-5.24.0/bin:/home/jkeenan/rakudo-star/bin:/home/jkeenan/rakudo-star/share/perl6/site/bin:/home/jkeenan/.rakudobrew/bin:/home/jkeenan/rakudo/bin:/home/jkeenan/scala-2.11.1/bin/:/home/jkeenan/bin/perl:/home/jkeenan/bin/shell:/home/jkeenan/go/bin:/home/jkeenan/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
     PERLBREW_BASHRC_VERSION=0.67
     PERLBREW_HOME=/home/jkeenan/.perlbrew
     PERLBREW_MANPATH=/home/jkeenan/perl5/perlbrew/perls/perl-5.24.0/man
 
PERLBREW_PATH=/home/jkeenan/perl5/perlbrew/bin:/home/jkeenan/perl5/perlbrew/perls/perl-5.24.0/bin
     PERLBREW_PERL=perl-5.24.0
     PERLBREW_ROOT=/home/jkeenan/perl5/perlbrew
     PERLBREW_VERSION=0.67
     PERL_BADLANG (unset)
     PERL_WORKDIR=/home/jkeenan/gitwork/perl
     SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Dec 4, 2016

From @jkeenan

0001-Account-for-WSL-in-assignment-to-dont_use_nlink.patch
From 02bf7330deeaa5dbc41d5c6d89a80d2c31e08c6b Mon Sep 17 00:00:00 2001
From: James E Keenan <jkeenan@cpan.org>
Date: Sun, 4 Dec 2016 08:47:26 -0500
Subject: [PATCH] Account for WSL in assignment to dont_use_nlink.

File::Find sees that $^O is 'linux' and uses nlink, which doesn't work.
Identify and account for Windows Subsystem on Linux (WSL).

Problem reported and revisions submitted by Thorsten Behrens on p5p list.
Incorporate suggestions by Uri Guttman.
---
 AUTHORS                        |  1 +
 ext/File-Find/lib/File/Find.pm | 34 +++++++++++++++++++++++-----------
 2 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index b341532..a72cbc2 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1187,6 +1187,7 @@ Thomas König
 Thomas Pfau			<pfau@nbpfaus.net>
 Thomas Sibley			<tsibley@cpan.org>
 Thomas Wegner			<wegner_thomas@yahoo.com>
+Thorsten Behrens			<tbehrens@outlook.com>
 Thorsten Glaser			<tg@mirbsd.org>
 Tim Adye			<T.J.Adye@rl.ac.uk>
 Tim Ayers			<tayers@bridge.com>
diff --git a/ext/File-Find/lib/File/Find.pm b/ext/File-Find/lib/File/Find.pm
index 03dac9f..67668e8 100644
--- a/ext/File-Find/lib/File/Find.pm
+++ b/ext/File-Find/lib/File/Find.pm
@@ -3,7 +3,7 @@ use 5.006;
 use strict;
 use warnings;
 use warnings::register;
-our $VERSION = '1.34';
+our $VERSION = '1.35';
 require Exporter;
 require Cwd;
 
@@ -14,6 +14,7 @@ our @EXPORT = qw(find finddepth);
 use strict;
 my $Is_VMS;
 my $Is_Win32;
+my $Is_Microsoft_WSL;
 
 require File::Basename;
 require File::Spec;
@@ -770,21 +771,32 @@ sub finddepth {
 $File::Find::skip_pattern    = qr/^\.{1,2}\z/;
 $File::Find::untaint_pattern = qr|^([-+@\w./]+)$|;
 
-# These are hard-coded for now, but may move to hint files.
-if ($^O eq 'VMS') {
-    $Is_VMS = 1;
-    $File::Find::dont_use_nlink = 1;
-}
-elsif ($^O eq 'MSWin32') {
-    $Is_Win32 = 1;
-}
-
 # this _should_ work properly on all platforms
 # where File::Find can be expected to work
 $File::Find::current_dir = File::Spec->curdir || '.';
 
+sub _microsoft_wsl_check {
+    return 0 unless $^O eq 'linux';
+    open my $pv, '<', '/proc/version' or die "Can't open < /proc/version: $!";
+    # Expecting /proc/version to look like this:
+    # Linux version 3.4.0-Microsoft (Microsoft@Microsoft.com) (gcc version 4.7 (GCC) ) #1 SMP PREEMPT Wed Dec 31 14:42:53 PST 2014
+    my $lv = <$pv>;
+
+    # If we locate either 'Microsoft' or 'WSL' (Windows Subsystem for Linux)
+    # in the string, we infer that we are on WSL.  See:
+    # https://msdn.microsoft.com/en-us/commandline/wsl/about
+
+    return 1 if (index($lv,'Microsoft') != -1 || index($lv,'WSL') != -1);
+    return 0;
+}
+
+$Is_VMS             = 1 if ($^O eq 'VMS');
+$Is_Win32           = 1 if ($^O eq 'MSWin32');
+$Is_Microsoft_WSL   = 1 if _microsoft_wsl_check();
+
 $File::Find::dont_use_nlink = 1
-    if $^O eq 'os2' || $^O eq 'dos' || $^O eq 'amigaos' || $Is_Win32 ||
+    if $^O eq 'os2' || $^O eq 'dos' || $^O eq 'amigaos' ||
+       $Is_Win32 || $Is_VMS || $Is_Microsoft_WSL ||
        $^O eq 'interix' || $^O eq 'cygwin' || $^O eq 'qnx' || $^O eq 'nto';
 
 # Set dont_use_nlink in your hint file if your system's stat doesn't
-- 
2.7.4

@p5pRT
Copy link
Author

p5pRT commented Dec 4, 2016

From @jkeenan

On Sun, 04 Dec 2016 14​:01​:55 GMT, jkeen@​verizon.net wrote​:

This is a bug report for perl from jkeenan@​cpan.org,
generated with the help of perlbug 1.40 running under perl 5.24.0.

-----------------------------------------------------------------
[Please describe your issue here]

This RT incorporates and builds upon discussion initiated by Thorsten
Behrens on the perl5-porters mailing list in a thread starting at​:
http​://www.nntp.perl.org/group/perl.perl5.porters/2016/12/msg241336.html.

Thorsten wrote​:

"As per discussion here
microsoft/WSL#186, WSL confuses
File​::Find. WSL is the "Windows Subsystem for Linux", which runs
Ubuntu
on top of Windows 10.

"File​::Find sees that $^O is 'linux' and uses nlink, which doesn't
work.
After some discussion, this code added to Find.pm special-cases for
WSL
and solves the issue[.]"

Discussion on the mailing list included feedback on the code from Uri
Guttman. When I inspected the parts of File​::Find which would be
patched, I realized that the way in which $File​::Find​::dont_use_nlink
was being assigned could do with some tidying. The patch attached
takes
Thorsten's approach to resolving the WSL issue and reflects Uri's
suggestions.

Please review.

(As we gain experience with WSL, we should in the future consider
checking for it in Configure. But let's deal with the presenting
problem first.)

Thank you very much.

Jim Keenan

Available for smoke-testing in this branch​:

smoke-me/jkeenan/130258-file-find-wls

Reports from VMS, Win32 and WLS would be appreciated.

Thank you very much.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Dec 4, 2016

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Dec 4, 2016

From tbehrens@outlook.com

Created by @jkeenan

This RT incorporates and builds upon discussion initiated by Thorsten
Behrens on the perl5-porters mailing list in a thread starting at​:
http​://www.nntp.perl.org/group/perl.perl5.porters/2016/12/msg241336.html.

Thorsten wrote​:

"As per discussion here
microsoft/WSL#186, WSL confuses
File​::Find. WSL is the "Windows Subsystem for Linux", which runs Ubuntu
on top of Windows 10.

"File​::Find sees that $^O is 'linux' and uses nlink, which doesn't work.
After some discussion, this code added to Find.pm special-cases for WSL
and solves the issue[.]"

Discussion on the mailing list included feedback on the code from Uri
Guttman. When I inspected the parts of File​::Find which would be
patched, I realized that the way in which $File​::Find​::dont_use_nlink
was being assigned could do with some tidying. The patch attached takes
Thorsten's approach to resolving the WSL issue and reflects Uri's
suggestions.

Please review.

(As we gain experience with WSL, we should in the future consider
checking for it in Configure. But let's deal with the presenting
problem first.)

Thank you very much.

Jim Keenan

Perl Info
---
Flags:
     category=library
     severity=low
     module=File::Find
---
Site configuration information for perl 5.24.0:

Configured by jkeenan at Mon May  9 18:37:23 EDT 2016.

Summary of my perl5 (revision 5 version 24 subversion 0) configuration:

   Platform:
     osname=linux, osvers=3.13.0-85-generic, archname=x86_64-linux
     uname='linux zareason 3.13.0-85-generic #129-ubuntu smp thu mar 17 
20:50:15 utc 2016 x86_64 x86_64 x86_64 gnulinux '
     config_args='-de 
-Dprefix=/home/jkeenan/perl5/perlbrew/perls/perl-5.24.0 
-Aeval:scriptdir=/home/jkeenan/perl5/perlbrew/perls/perl-5.24.0/bin'
     hint=recommended, useposix=true, d_sigaction=define
     useithreads=undef, usemultiplicity=undef
     use64bitint=define, use64bitall=define, uselongdouble=undef
     usemymalloc=n, bincompat5005=undef
   Compiler:
     cc='cc', ccflags ='-fwrapv -fno-strict-aliasing -pipe 
-fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE 
-D_FILE_OFFSET_BITS=64',
     optimize='-O2',
     cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector 
-I/usr/local/include'
     ccversion='', gccversion='4.8.4', gccosandvers=''
     intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678, 
doublekind=3
     d_longlong=define, longlongsize=8, d_longdbl=define, 
longdblsize=16, longdblkind=3
     ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', 
lseeksize=8
     alignbytes=8, prototype=define
   Linker and Libraries:
     ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
     libpth=/usr/local/lib 
/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed 
/usr/include/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib/../lib 
/usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib /lib64 /usr/lib64
     libs=-lpthread -lnsl -ldb -ldl -lm -lcrypt -lutil -lc
     perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
     libc=libc-2.19.so, so=so, useshrplib=false, libperl=libperl.a
     gnulibc_version='2.19'
   Dynamic Linking:
     dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
     cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib 
-fstack-protector'


---
@INC for perl 5.24.0:
 
/home/jkeenan/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0/x86_64-linux
     /home/jkeenan/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0
     /home/jkeenan/perl5/perlbrew/perls/perl-5.24.0/lib/5.24.0/x86_64-linux
     /home/jkeenan/perl5/perlbrew/perls/perl-5.24.0/lib/5.24.0
     .

---
Environment for perl 5.24.0:
     HOME=/home/jkeenan
     LANG=en_US.utf-8
     LANGUAGE=en_US
     LD_LIBRARY_PATH (unset)
     LOGDIR (unset)
 
PATH=/home/jkeenan/perl5/perlbrew/bin:/home/jkeenan/perl5/perlbrew/perls/perl-5.24.0/bin:/home/jkeenan/rakudo-star/bin:/home/jkeenan/rakudo-star/share/perl6/site/bin:/home/jkeenan/.rakudobrew/bin:/home/jkeenan/rakudo/bin:/home/jkeenan/scala-2.11.1/bin/:/home/jkeenan/bin/perl:/home/jkeenan/bin/shell:/home/jkeenan/go/bin:/home/jkeenan/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
     PERLBREW_BASHRC_VERSION=0.67
     PERLBREW_HOME=/home/jkeenan/.perlbrew
     PERLBREW_MANPATH=/home/jkeenan/perl5/perlbrew/perls/perl-5.24.0/man
 
PERLBREW_PATH=/home/jkeenan/perl5/perlbrew/bin:/home/jkeenan/perl5/perlbrew/perls/perl-5.24.0/bin
     PERLBREW_PERL=perl-5.24.0
     PERLBREW_ROOT=/home/jkeenan/perl5/perlbrew
     PERLBREW_VERSION=0.67
     PERL_BADLANG (unset)
     PERL_WORKDIR=/home/jkeenan/gitwork/perl
     SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Dec 4, 2016

From @jkeenan

On Sun, 04 Dec 2016 16​:52​:16 GMT, tbehrens@​outlook.com wrote​:

Thank you! I think Leon is right though that "or die" is a bad idea.
There may be an $^O eq 'linux' that doesn't have /proc, and breaking
other Linuxes because of WSL would be bad. So in your patch, which is
lovely btw, maybe do​:

Yes, I didn't see this morning's discussion on list until after I had created this ticket. I will review the discussion and your revised subroutine.

+sub _microsoft_wsl_check {
+ return 0 unless $^O eq 'linux';
+ if (open my $pv, '<', '/proc/version') {
+ # Expecting /proc/version to look like this​:
+ # Linux version 3.4.0-Microsoft (Microsoft@​Microsoft.com) (gcc
version 4.7 (GCC) ) #1 SMP PREEMPT Wed Dec 31 14​:42​:53 PST 2014
+ my $lv = <$pv>;
+
+ # If we locate either 'Microsoft' or 'WSL' (Windows Subsystem
for Linux)
+ # in the string, we infer that we are on WSL. See​:
+ # https://msdn.microsoft.com/en-us/commandline/wsl/about
+
+ return 1 if (index($lv,'Microsoft') != -1 || index($lv,'WSL')
!= -1);
+ }
+ return 0;
+}

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Dec 4, 2016

From @jkeenan

On Sun, 04 Dec 2016 21​:12​:10 GMT, jkeenan wrote​:

On Sun, 04 Dec 2016 16​:52​:16 GMT, tbehrens@​outlook.com wrote​:

Thank you! I think Leon is right though that "or die" is a bad idea.
There may be an $^O eq 'linux' that doesn't have /proc, and breaking
other Linuxes because of WSL would be bad. So in your patch, which is
lovely btw, maybe do​:

Yes, I didn't see this morning's discussion on list until after I had
created this ticket. I will review the discussion and your revised
subroutine.

+sub _microsoft_wsl_check {
+ return 0 unless $^O eq 'linux';
+ if (open my $pv, '<', '/proc/version') {
+ # Expecting /proc/version to look like this​:
+ # Linux version 3.4.0-Microsoft (Microsoft@​Microsoft.com)
(gcc
version 4.7 (GCC) ) #1 SMP PREEMPT Wed Dec 31 14​:42​:53 PST 2014
+ my $lv = <$pv>;
+
+ # If we locate either 'Microsoft' or 'WSL' (Windows Subsystem
for Linux)
+ # in the string, we infer that we are on WSL. See​:
+ # https://msdn.microsoft.com/en-us/commandline/wsl/about
+
+ return 1 if (index($lv,'Microsoft') != -1 || index($lv,'WSL')
!= -1);
+ }
+ return 0;
+}

Supplementary patch file attached and committed to the branch mentioned earlier.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Dec 4, 2016

From @jkeenan

0002-Don-t-die-if-unable-to-open-proc-version.patch
From b5d3735edaf1ce4d6df342a84098adf26cb828ec Mon Sep 17 00:00:00 2001
From: James E Keenan <jkeenan@cpan.org>
Date: Sun, 4 Dec 2016 16:52:25 -0500
Subject: [PATCH 2/2] Don't die if unable to open /proc/version.

As some Linuxes may not have that file.
---
 ext/File-Find/lib/File/Find.pm | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/ext/File-Find/lib/File/Find.pm b/ext/File-Find/lib/File/Find.pm
index 67668e8..822868d 100644
--- a/ext/File-Find/lib/File/Find.pm
+++ b/ext/File-Find/lib/File/Find.pm
@@ -777,16 +777,17 @@ $File::Find::current_dir = File::Spec->curdir || '.';
 
 sub _microsoft_wsl_check {
     return 0 unless $^O eq 'linux';
-    open my $pv, '<', '/proc/version' or die "Can't open < /proc/version: $!";
-    # Expecting /proc/version to look like this:
-    # Linux version 3.4.0-Microsoft (Microsoft@Microsoft.com) (gcc version 4.7 (GCC) ) #1 SMP PREEMPT Wed Dec 31 14:42:53 PST 2014
-    my $lv = <$pv>;
+    if (open my $pv, '<', '/proc/version') {
+        # Expecting /proc/version to look like this:
+        # Linux version 3.4.0-Microsoft (Microsoft@Microsoft.com) (gcc version 4.7 (GCC) ) #1 SMP PREEMPT Wed Dec 31 14:42:53 PST 2014
+        my $lv = <$pv>;
 
-    # If we locate either 'Microsoft' or 'WSL' (Windows Subsystem for Linux)
-    # in the string, we infer that we are on WSL.  See:
-    # https://msdn.microsoft.com/en-us/commandline/wsl/about
+        # If we locate either 'Microsoft' or 'WSL' (Windows Subsystem for Linux)
+        # in the string, we infer that we are on WSL.  See:
+        # https://msdn.microsoft.com/en-us/commandline/wsl/about
 
-    return 1 if (index($lv,'Microsoft') != -1 || index($lv,'WSL') != -1);
+        return 1 if (index($lv,'Microsoft') != -1 || index($lv,'WSL') != -1);
+    }
     return 0;
 }
 
-- 
2.7.4

@p5pRT
Copy link
Author

p5pRT commented Dec 6, 2016

From tbehrens@outlook.com

Please put this work on hold. Microsoft may fix it on their end in the WSL layer. WSL bug 910 (microsoft/WSL#910), which is directly related to this, is marked as "fixinbound". This means MS believes they have a fix and it will become available in a future test build, called "Insider" builds, at which point it will be marked "fixed".
I will test against future builds.

Yours

Thorsten Behrens
(Sent from mobile)

@p5pRT
Copy link
Author

p5pRT commented Dec 6, 2016

@jkeenan - Status changed from 'open' to 'stalled'

@p5pRT
Copy link
Author

p5pRT commented Dec 6, 2016

From tbehrens@outlook.com

This issue has been resolved by Microsoft by changing the links count returned from “always 2” to “always 0”. See microsoft/WSL#910 .

This patch can be shelved. GA of the fixed Windows/WSL code is expected in Q1, likely sometime February 2017.

@p5pRT
Copy link
Author

p5pRT commented Dec 6, 2016

The RT System itself - Status changed from 'stalled' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Dec 6, 2016

@jkeenan - Status changed from 'open' to 'stalled'

@p5pRT
Copy link
Author

p5pRT commented Dec 8, 2016

From @xsawyerx

This can be resolved as already fixed without applying the patch. Please
see Leon's comment here​:

http​://nntp.perl.org/group/perl.perl5.porters/241446

On 12/04/2016 11​:03 PM, James E Keenan via RT wrote​:

On Sun, 04 Dec 2016 21​:12​:10 GMT, jkeenan wrote​:

On Sun, 04 Dec 2016 16​:52​:16 GMT, tbehrens@​outlook.com wrote​:

Thank you! I think Leon is right though that "or die" is a bad idea.
There may be an $^O eq 'linux' that doesn't have /proc, and breaking
other Linuxes because of WSL would be bad. So in your patch, which is
lovely btw, maybe do​:

Yes, I didn't see this morning's discussion on list until after I had
created this ticket. I will review the discussion and your revised
subroutine.

+sub _microsoft_wsl_check {
+ return 0 unless $^O eq 'linux';
+ if (open my $pv, '<', '/proc/version') {
+ # Expecting /proc/version to look like this​:
+ # Linux version 3.4.0-Microsoft (Microsoft@​Microsoft.com)
(gcc
version 4.7 (GCC) ) #1 SMP PREEMPT Wed Dec 31 14​:42​:53 PST 2014
+ my $lv = <$pv>;
+
+ # If we locate either 'Microsoft' or 'WSL' (Windows Subsystem
for Linux)
+ # in the string, we infer that we are on WSL. See​:
+ # https://msdn.microsoft.com/en-us/commandline/wsl/about
+
+ return 1 if (index($lv,'Microsoft') != -1 || index($lv,'WSL')
!= -1);
+ }
+ return 0;
+}

Supplementary patch file attached and committed to the branch mentioned earlier.

@p5pRT
Copy link
Author

p5pRT commented Dec 8, 2016

The RT System itself - Status changed from 'stalled' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Dec 8, 2016

@jkeenan - Status changed from 'open' to 'resolved'

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