add comments to clarify the initial handshake
[scpubgit/Tak.git] / lib / Tak / STDIOSetup.pm
index c06efbc..d090f06 100644 (file)
@@ -5,11 +5,13 @@ use Log::Contextual::SimpleLogger;
 use Tak::ConnectionService;
 use Tak::Router;
 use Tak;
+use IO::Handle;
 use strictures 1;
 
 sub run {
   open my $stdin, '<&', \*STDIN or die "Duping stdin: $!";
   open my $stdout, '>&', \*STDOUT or die "Duping stdout: $!";
+  $stdout->autoflush(1);
   # if we don't re-open them then 0 and 1 get re-used - which is not
   # only potentially bloody confusing but results in warnings like:
   # "Filehandle STDOUT reopened as STDIN only for input"
@@ -36,7 +38,9 @@ sub run {
     $0 = 'tak-stdio-node';
   }
   log_debug { "Node starting" };
-  print $stdout "UP\n";
+  # Tell the other end that we've finished messing around with file
+  # descriptors and that it's therefore safe to start sending requests.
+  print $stdout "Ssyshere\n";
   Tak->loop_until($done);
 }