version 1.7, 2005/02/05 23:00:26
|
version 1.8, 2005/02/06 21:23:07
|
|
|
// Author: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) | // Author: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) |
// Jenny Yu, Hewlett-Packard Company (jenny_yu@hp.com) | // Jenny Yu, Hewlett-Packard Company (jenny_yu@hp.com) |
// | // |
// Modified By: |
// Modified By: Sean Keenan, Hewlett-Packard Company (sean.keenan@hp.com) |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
| |
#if defined (PEGASUS_OS_TYPE_WINDOWS) | #if defined (PEGASUS_OS_TYPE_WINDOWS) |
#include <windows.h> // For CreateProcess() | #include <windows.h> // For CreateProcess() |
#else |
#elif defined (PEGASUS_OS_OS400) |
# if defined (PEGASUS_OS_OS400) |
|
# include <unistd.cleinc> | # include <unistd.cleinc> |
|
#elif defined (PEGASUS_OS_VMS) |
|
# include <perror.h> |
|
# include <climsgdef.h> |
|
# include <stdio.h> |
|
# include <stdlib.h> |
|
# include <string.h> |
|
# include <processes.h> |
|
# include <unixio.h> |
# else | # else |
# include <unistd.h> // For fork(), exec(), and _exit() | # include <unistd.h> // For fork(), exec(), and _exit() |
# endif |
|
#include <errno.h> | #include <errno.h> |
#endif | #endif |
| |
|
|
| |
CloseHandle(piProcInfo.hProcess); | CloseHandle(piProcInfo.hProcess); |
CloseHandle(piProcInfo.hThread); | CloseHandle(piProcInfo.hThread); |
|
|
|
#elif defined (PEGASUS_OS_VMS) |
|
|
|
// |
|
// fork and exec the child process |
|
// |
|
int status; |
|
|
|
status = vfork (); |
|
switch (status) |
|
{ |
|
case 0: |
|
try |
|
{ |
|
// |
|
// Execute the cimprovagt program |
|
// |
|
String agentCommandPath = |
|
ConfigManager::getHomedPath(PEGASUS_PROVIDER_AGENT_PROC_NAME); |
|
CString agentCommandPathCString = agentCommandPath.getCString(); |
|
|
|
char readHandle[32]; |
|
char writeHandle[32]; |
|
pipeToAgent->exportReadHandle(readHandle); |
|
pipeFromAgent->exportWriteHandle(writeHandle); |
|
|
|
if ((status = execl(agentCommandPathCString, agentCommandPathCString, |
|
readHandle, writeHandle, |
|
(const char*)_moduleName.getCString(), (char*)0)) == -1); |
|
{ |
|
// If we're still here, there was an error |
|
Tracer::trace(TRC_DISCARDED_DATA, Tracer::LEVEL2, |
|
"execl() failed. errno = %d.", errno); |
|
_exit(1); |
|
} |
|
break; |
|
} |
|
catch (...) |
|
{ |
|
// There's not much we can do here in no man's land |
|
try |
|
{ |
|
PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2, |
|
"Caught exception before calling execl()."); |
|
} |
|
catch (...) |
|
{ |
|
} |
|
_exit(1); |
|
} |
|
break; |
|
|
|
case -1: |
|
Tracer::trace(TRC_PROVIDERMANAGER, Tracer::LEVEL2, |
|
"fork() failed. errno = %d.", errno); |
|
PEG_METHOD_EXIT(); |
|
throw Exception(MessageLoaderParms( |
|
"ProviderManager.OOPProviderManagerRouter.CIMPROVAGT_START_FAILED", |
|
"Failed to start cimprovagt \"$0\".", |
|
_moduleName)); |
|
break; |
|
|
|
default: |
#else | #else |
pid_t pid = fork(); | pid_t pid = fork(); |
if (pid < 0) | if (pid < 0) |
|
|
_pipeFromAgent.reset(pipeFromAgent.release()); | _pipeFromAgent.reset(pipeFromAgent.release()); |
| |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
|
|
|
#if defined (PEGASUS_OS_VMS) |
|
// |
|
// Denote end of switch |
|
// |
|
} |
|
#endif |
} | } |
| |
// Note: Caller must lock _agentMutex | // Note: Caller must lock _agentMutex |