From 11e0a3b1f89458b8d273b162031de55232b88419 Mon Sep 17 00:00:00 2001
From: curt <curt>
Date: Mon, 3 Mar 2003 17:48:09 +0000
Subject: [PATCH] Don't remove the named pipe on a "Reset" or position change
 (i.e. when FGExternalPipe is destructed.)  This leaves the name pipe hanging
 around even after flightgear exits, but assuming we put the files in /tmp
 that shouldn't be a big deal.

---
 src/FDM/ExternalPipe/ExternalPipe.cxx | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/src/FDM/ExternalPipe/ExternalPipe.cxx b/src/FDM/ExternalPipe/ExternalPipe.cxx
index da73ca069..bdad4bd21 100644
--- a/src/FDM/ExternalPipe/ExternalPipe.cxx
+++ b/src/FDM/ExternalPipe/ExternalPipe.cxx
@@ -89,6 +89,8 @@ FGExternalPipe::FGExternalPipe( double dt, string name ) {
 FGExternalPipe::~FGExternalPipe() {
     delete [] buf;
 
+    SG_LOG( SG_IO, SG_INFO, "Closing up the ExternalPipe." );
+    
 #if defined( HAVE_SYS_TYPES_H ) && defined( HAVE_SYS_STAT_H )
     // close
     int result;
@@ -102,18 +104,6 @@ FGExternalPipe::~FGExternalPipe() {
         SG_LOG( SG_IO, SG_ALERT, "Unable to close named pipe: "
                 << fifo_name_2 );
     }
-
-    // remove the file system entry
-    result = unlink( fifo_name_1.c_str() );
-    if ( result == -1 ) {
-        SG_LOG( SG_IO, SG_ALERT, "Unable to remove named pipe: "
-                << fifo_name_1 );
-    }
-    result = unlink( fifo_name_2.c_str() );
-    if ( result == -1 ) {
-        SG_LOG( SG_IO, SG_ALERT, "Unable to remove named pipe: "
-                << fifo_name_2 );
-    }
 #endif
 }
 
@@ -193,6 +183,8 @@ void FGExternalPipe::init() {
 // Run an iteration of the EOM.
 void FGExternalPipe::update( double dt ) {
 #if defined( HAVE_SYS_TYPES_H ) && defined( HAVE_SYS_STAT_H )
+    // SG_LOG( SG_IO, SG_INFO, "Start FGExternalPipe::udpate()" );
+
     int length;
     int result;
 
@@ -216,9 +208,8 @@ void FGExternalPipe::update( double dt ) {
         SG_LOG( SG_IO, SG_ALERT, "Write error to named pipe: "
                 << fifo_name_1 );
     }
-    // cout << "wrote to pipe" << endl;
+    // cout << "  wrote to pipe" << endl;
 
-    // Read next set of FDM data (blocking enabled to maintain 'sync')
     length = sizeof(fdm);
     result = std::read( pd2, (char *)(& fdm), length );
     if ( result == -1 ) {
@@ -227,5 +218,7 @@ void FGExternalPipe::update( double dt ) {
     }
     FGNetFDM2Props( &fdm, false );
     // cout << "read from pipe" << endl;
+
+    // SG_LOG( SG_IO, SG_INFO, "  End FGExternalPipe::udpate()" );
 #endif
 }