Upgrade to PathTools 3.25
[p5sagit/p5-mst-13.2.git] / lib / Net / Cmd.pm
index 0324a9b..aa1a193 100644 (file)
@@ -1,6 +1,6 @@
 # Net::Cmd.pm $Id: //depot/libnet/Net/Cmd.pm#34 $
 #
-# Copyright (c) 1995-1997 Graham Barr <gbarr@pobox.com>. All rights reserved.
+# Copyright (c) 1995-2006 Graham Barr <gbarr@pobox.com>. All rights reserved.
 # This program is free software; you can redistribute it and/or
 # modify it under the same terms as Perl itself.
 
@@ -21,7 +21,7 @@ BEGIN {
   }
 }
 
-$VERSION = "2.25";
+$VERSION = "2.27_01";
 @ISA     = qw(Exporter);
 @EXPORT  = qw(CMD_INFO CMD_OK CMD_MORE CMD_REJECT CMD_ERROR CMD_PENDING);
 
@@ -266,7 +266,9 @@ sub getline
   {
    my $timeout = $cmd->timeout || undef;
    my $rout;
-   if (select($rout=$rin, undef, undef, $timeout))
+
+   my $select_ret = select($rout=$rin, undef, undef, $timeout);
+   if ($select_ret > 0)
     {
      unless (sysread($cmd, $buf="", 1024))
       {
@@ -287,7 +289,8 @@ sub getline
     }
    else
     {
-     carp("$cmd: Timeout") if($cmd->debug);
+     my $msg = $select_ret ? "Error or Interrupted: $!" : "Timeout";
+     carp("$cmd: $msg") if($cmd->debug);
      return undef;
     }
   }
@@ -431,7 +434,8 @@ sub datasend
  while($len)
   {
    my $wout;
-   if (select(undef,$wout=$win, undef, $timeout) > 0)
+   my $s = select(undef,$wout=$win, undef, $timeout);
+   if ((defined $s and $s > 0) or -f $cmd) # -f for testing on win32
     {
      my $w = syswrite($cmd, $line, $len, $offset);
      unless (defined($w))
@@ -748,7 +752,7 @@ Returns a filehandle tied to the Net::Cmd object.  After issuing a
 command, you may read from this filehandle using read() or <>.  The
 filehandle will return EOF when the final dot is encountered.
 Similarly, you may write to the filehandle in order to send data to
-the server after issuing a commmand that expects data to be written.
+the server after issuing a command that expects data to be written.
 
 See the Net::POP3 and Net::SMTP modules for examples of this.
 
@@ -766,12 +770,8 @@ Graham Barr <gbarr@pobox.com>
 
 =head1 COPYRIGHT
 
-Copyright (c) 1995-1997 Graham Barr. All rights reserved.
+Copyright (c) 1995-2006 Graham Barr. All rights reserved.
 This program is free software; you can redistribute it and/or modify
 it under the same terms as Perl itself.
 
-=for html <hr>
-
-I<$Id: //depot/libnet/Net/Cmd.pm#34 $>
-
 =cut