4 unless(grep /blib/, @INC) {
14 if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bSocket\b/) {
15 $reason = 'Socket extension unavailable';
17 elsif ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bIO\b/) {
18 $reason = 'IO extension unavailable';
20 elsif ($^O eq 'os2') {
23 eval {IO::Socket::pack_sockaddr_un('/foo/bar') || 1}
24 or $@ !~ /not implemented/ or
25 $reason = 'compiled without TCP/IP stack v4';
27 elsif ($^O =~ m/^(?:qnx|nto|vos)$/ ) {
28 $reason = 'Not implemented';
30 elsif (! $Config{'d_fork'}) {
34 print "1..0 # Skip: $reason\n";
41 # Test if we can create the file within the tmp directory
42 if (-e $PATH or not open(TEST, ">$PATH") and $^O ne 'os2') {
43 print "1..0 # Skip: cannot open '$PATH' for write\n";
47 unlink($PATH) or $^O eq 'os2' or die "Can't unlink $PATH: $!";
55 $listen = IO::Socket::UNIX->new(Local => $PATH, Listen => 0);
57 # Sometimes UNIX filesystems are mounted for security reasons
58 # with "nodev" option which spells out "no" for creating UNIX
59 # local sockets. Therefore we will retry with a File::Temp
60 # generated filename from a temp directory.
61 unless (defined $listen) {
62 eval { require File::Temp };
64 import File::Temp 'mktemp';
65 for my $TMPDIR ($ENV{TMPDIR}, "/tmp") {
66 if (defined $TMPDIR && -d $TMPDIR && -w $TMPDIR) {
67 $PATH = mktemp("$TMPDIR/sXXXXXXXX");
68 last if $listen = IO::Socket::UNIX->new(Local => $PATH,
73 defined $listen or die "$PATH: $!";
79 $sock = $listen->accept();
84 print $sock->getline();
91 unlink($PATH) || $^O eq 'os2' || warn "Can't unlink $PATH: $!";
95 print "# accept() failed: $!\n";
97 print "not ok $_ # accept failed\n";
100 } elsif(defined $pid) {
102 $sock = IO::Socket::UNIX->new(Peer => $PATH) or die "$!";
104 print $sock "ok 3\n";
106 print $sock->getline();