develooper Front page | perl.perl5.porters | Postings from April 2006

Re: Making IO::Socket pass test on Win32

Thread Previous | Thread Next
From:
demerphq
Date:
April 2, 2006 01:07
Subject:
Re: Making IO::Socket pass test on Win32
Message ID:
9b18b3110604020107o6a0b594cwfc2344a172c360b0@mail.gmail.com
On 3/31/06, Steve Hay <steve.hay@uk.radan.com> wrote:
> demerphq wrote:
> > On 3/31/06, Steve Hay <steve.hay@uk.radan.com> wrote:
> >> demerphq wrote:
> >>> diff -burd d:\.cpan\build\IO-1.23\/t/io_sock.t IO-1.23/t/io_sock.t
> >>> --- d:\.cpan\build\IO-1.23\/t/io_sock.t       2006-03-26 04:27:13.000000000 +0200
> >>> +++ IO-1.23/t/io_sock.t       2006-03-26 14:47:08.034134600 +0200
> >>> @@ -17,7 +17,7 @@
> >>>      elsif ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bIO\b/) {
> >>>       $reason = 'IO extension unavailable';
> >>>      }
> >>> -    elsif (! $Config{'d_fork'}) {
> >>> +    elsif (! $Config{'d_fork'} && $^O ne "MSWin32" ) {
> >>>       $reason = 'no fork';
> >>>      }
> >>>      if ($reason) {
> >> This bit makes io_sock.t fail tests 2-26 when using a non-threaded perl
> >> on Win32:
> >>
> >> C:\p5p\bleadperl\t>.\perl -I..\lib ..\ext\IO\t\io_sock.t
> >> 1..26
> >> ok 1
> >> The fork function is unimplemented at ..\ext\IO\t\io_sock.t line 59.
> >
> > Any recommendation on a better Config test to use?
>
> The fork() emulation on Win32 is provided by building with all three of
> the Makefile options: USE_MULTI, USE_ITHREADS and USE_IMP_SYS.
>
> The former two can be tested using $Config{usemultiplicity} and
> $Config{useithreads} respectively, but there is no %Config entry
> corresponding to USE_IMP_SYS.  The effect of USE_IMP_SYS is to set
> -DPERL_IMPLICIT_SYS and link in perllib.obj, so all you can really do is
> to look for -DPERL_IMPLICIT_SYS in $Config{ccflags}.
>
> The other obvious way to tell, I guess, is to suck it and see.  The
> following works OK for me:
>
> eval {
>    my $pid;
>    if ($pid = fork()) {
>      waitpid($pid, 0);
>    }
>    else {
>      exit;
>    }
>    1;
> };
> if ($@) {
>    print "No fork()\n";
> }
> else {
>    print "Have fork()\n";
> }

I reduced that down a bit so it could be used as a conditional EXPR.
Could you try the attached patch on your various Win32 builds?

Cheers,
yves


--
perl -Mre=debug -e "/just|another|perl|hacker/"

Thread Previous | Thread Next


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