Minor updates:
- CSelectableCore: - Allow ForkPipeHandle to change ExecPath - Remove parent/child process test comments - Move FD operations methods from private -> public
This commit is contained in:
@@ -183,7 +183,7 @@ bool CSelectableCore::SetPortHandle( THandle * Handle, const char * FileName )
|
|||||||
bool CSelectableCore::SetForkPipeHandle( THandle * Handle, const char * ExecPath )
|
bool CSelectableCore::SetForkPipeHandle( THandle * Handle, const char * ExecPath )
|
||||||
{
|
{
|
||||||
// Validate
|
// Validate
|
||||||
if (!Handle || (Handle->Type != ctNone) || !ExecPath) {
|
if (!Handle || ((Handle->Type != ctNone) && (Handle->Type != ctForkPipe)) || !ExecPath) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -405,16 +405,12 @@ int CSelectableCore::OpenForkPipe( THandle * Handle )
|
|||||||
close( pipefd[0] );
|
close( pipefd[0] );
|
||||||
Handle->FD = pipefd[1];
|
Handle->FD = pipefd[1];
|
||||||
|
|
||||||
write( Handle->FD, "testing\n", 8 );
|
|
||||||
|
|
||||||
// Log event
|
// Log event
|
||||||
if (Log) Log->Message( DebugLevel, dlMedium, "%s: Handle '%s' - Process forked successfully", Name, Handle->Name );
|
if (Log) Log->Message( DebugLevel, dlMedium, "%s: Handle '%s' - Process forked successfully", Name, Handle->Name );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Fork success - this is child
|
// Fork success - this is child
|
||||||
printf( "child\n" );
|
|
||||||
|
|
||||||
// Replace stdin with Read-end of pipe
|
// Replace stdin with Read-end of pipe
|
||||||
close( 0 );
|
close( 0 );
|
||||||
dup( pipefd[0] );
|
dup( pipefd[0] );
|
||||||
|
|||||||
@@ -186,11 +186,6 @@ protected:
|
|||||||
virtual int OpenClientSocket( THandle * Handle );
|
virtual int OpenClientSocket( THandle * Handle );
|
||||||
|
|
||||||
// Mutual Operations
|
// 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 ReadFromFD( int FD, char * Data, int MaxLen );
|
||||||
int WriteToFD( int FD, const char * Data, int Len, bool Force );
|
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 SetSocketHandle( THandle * Handle, EConnectType Type, const char * Address, const int PortNo, bool KeepAlive );
|
||||||
bool ClearHandle( THandle * Handle );
|
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
|
// FD operations
|
||||||
inline virtual int Open( const char * HandleName ) { return (Open( GetHandle( HandleName ))); };
|
inline virtual int Open( const char * HandleName ) { return (Open( GetHandle( HandleName ))); };
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user