From c2acb4b77d1400424a698eb434f5cd6d01d2d5fc Mon Sep 17 00:00:00 2001 From: Charl Wentzel Date: Mon, 24 Oct 2016 17:53:50 +0200 Subject: [PATCH] Minor updates: - CSelectableCore: - Allow ForkPipeHandle to change ExecPath - Remove parent/child process test comments - Move FD operations methods from private -> public --- SelectableCore.cpp | 6 +----- SelectableCore.h | 11 ++++++----- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/SelectableCore.cpp b/SelectableCore.cpp index 98793b3..1e430f4 100644 --- a/SelectableCore.cpp +++ b/SelectableCore.cpp @@ -183,7 +183,7 @@ bool CSelectableCore::SetPortHandle( THandle * Handle, const char * FileName ) bool CSelectableCore::SetForkPipeHandle( THandle * Handle, const char * ExecPath ) { // Validate - if (!Handle || (Handle->Type != ctNone) || !ExecPath) { + if (!Handle || ((Handle->Type != ctNone) && (Handle->Type != ctForkPipe)) || !ExecPath) { return false; } @@ -405,16 +405,12 @@ int CSelectableCore::OpenForkPipe( THandle * Handle ) close( pipefd[0] ); Handle->FD = pipefd[1]; - write( Handle->FD, "testing\n", 8 ); - // Log event if (Log) Log->Message( DebugLevel, dlMedium, "%s: Handle '%s' - Process forked successfully", Name, Handle->Name ); } else { // Fork success - this is child - printf( "child\n" ); - // Replace stdin with Read-end of pipe close( 0 ); dup( pipefd[0] ); diff --git a/SelectableCore.h b/SelectableCore.h index fca14b0..0a6168d 100644 --- a/SelectableCore.h +++ b/SelectableCore.h @@ -186,11 +186,6 @@ protected: virtual int OpenClientSocket( THandle * Handle ); // Mutual Operations - virtual int Open( THandle * Handle ); - virtual bool Close( THandle * Handle, bool CloseChildren = false ); - virtual bool Read( THandle * Handle ); - virtual bool Write( THandle * Handle ); - int ReadFromFD( int FD, char * Data, int MaxLen ); int WriteToFD( int FD, const char * Data, int Len, bool Force ); @@ -235,6 +230,12 @@ public: bool SetSocketHandle( THandle * Handle, EConnectType Type, const char * Address, const int PortNo, bool KeepAlive ); bool ClearHandle( THandle * Handle ); + // FD Operations + virtual int Open( THandle * Handle ); + virtual bool Close( THandle * Handle, bool CloseChildren = false ); + virtual bool Read( THandle * Handle ); + virtual bool Write( THandle * Handle ); + // FD operations inline virtual int Open( const char * HandleName ) { return (Open( GetHandle( HandleName ))); };