Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 6 additions & 38 deletions src/coreclr/pal/src/handlemgr/handleapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,31 +107,9 @@ CorUnix::InternalDuplicateHandle(
PAL_ERROR palError = NO_ERROR;
IPalObject *pobjSource = NULL;

DWORD source_process_id;
DWORD target_process_id;
DWORD cur_process_id;

cur_process_id = GetCurrentProcessId();
source_process_id = PROCGetProcessIDFromHandle(hSourceProcess);
target_process_id = PROCGetProcessIDFromHandle(hTargetProcess);

/* Check validity of process handles */
if (0 == source_process_id || 0 == target_process_id)
{
ASSERT("Can't duplicate handle: invalid source or destination process");
palError = ERROR_INVALID_PARAMETER;
goto InternalDuplicateHandleExit;
}

/* At least source or target process should be the current process. */
if (source_process_id != cur_process_id
&& target_process_id != cur_process_id)
{
ASSERT("Can't duplicate handle : neither source or destination"
"processes are from current process");
palError = ERROR_INVALID_PARAMETER;
goto InternalDuplicateHandleExit;
}
/* We do not support other process in PAL */
_ASSERTE(hSourceProcess == hPseudoCurrentProcess);
_ASSERTE(hTargetProcess == hPseudoCurrentProcess);

if (FALSE != bInheritHandle)
{
Expand Down Expand Up @@ -169,16 +147,6 @@ CorUnix::InternalDuplicateHandle(
goto InternalDuplicateHandleExit;
}

// Handles can't be remoted cross-process.
// Just return the same handle.
if (source_process_id != cur_process_id
|| target_process_id != cur_process_id)
{
*phDuplicate = hSource;
palError = NO_ERROR;
goto InternalDuplicateHandleExit;
}

//
// Obtain the source IPalObject
//
Expand All @@ -200,10 +168,10 @@ CorUnix::InternalDuplicateHandle(
}
else if (hPseudoCurrentProcess == hSource)
{
/* The only pseudo handle is invariant */
TRACE("Duplicating process pseudo handle(%p)\n", hSource);

pobjSource = g_pobjProcess;
pobjSource->AddReference();
*phDuplicate = hPseudoCurrentProcess;
goto InternalDuplicateHandleExit;
}
Comment thread
huoyaoyuan marked this conversation as resolved.
else if (hPseudoCurrentThread == hSource)
{
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/pal/src/include/pal/corunix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ namespace CorUnix
otiFile,
otiFileMapping,
otiSocket,
otiProcess,
otiThread,
otiIOCompletionPort,
ObjectTypeIdCount // This entry must come last in the enumeration
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/pal/src/include/pal/palinternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,4 @@ const char StackOverflowMessage[] = "Stack overflow.\n";

#endif // __cplusplus

DWORD PALAPI GetCurrentSessionId();

#endif /* _PAL_INTERNAL_H_ */
12 changes: 1 addition & 11 deletions src/coreclr/pal/src/include/pal/process.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ extern "C"
*/
extern Volatile<LONG> terminator;

// The process and session ID of this process, so we can avoid excessive calls to getpid() and getsid().
// The process ID of this process, so we can avoid excessive calls to getpid().
extern DWORD gPID;
extern DWORD gSID;

extern LPWSTR pAppDir;

Expand All @@ -50,15 +49,6 @@ extern int gApplicationGroupIdLength;
#endif // __APPLE__
extern PathCharString *gSharedFilesPath;

/*++
Function:
PROCGetProcessIDFromHandle

Abstract
Return the process ID from a process handle
--*/
DWORD PROCGetProcessIDFromHandle(HANDLE hProcess);

/*++
Function:
PROCCreateInitialProcess
Expand Down
39 changes: 0 additions & 39 deletions src/coreclr/pal/src/include/pal/procobj.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,43 +23,6 @@ Module Name:

namespace CorUnix
{
extern CObjectType otProcess;

//
// Ideally dwProcessId would be part of the process object's immutable
// data. Doing so, though, creates complications in CreateProcess. The
// contents of the immutable data for a new object must be set before
// that object is registered with the object manager (as the object
// manager may make a copy of the immutable data). The PID for a new
// process, though, is not known until after creation. Registering the
// process object after process creation creates an undesirable error path
// -- if we are not able to register the process object (say, because of
// a low resource condition) we would be forced to return an error to
// the caller of CreateProcess, even though the new process was actually
// created...
//
// Note: we could work around this by effectively always going down
// the create suspended path. That is, the new process would not exec until
// the parent process released it. It's unclear how much benefit this would
// provide us.
//

class CProcProcessLocalData
{
public:
CProcProcessLocalData()
:
dwProcessId(0)
{
};

~CProcProcessLocalData()
{
};

DWORD dwProcessId;
};

PAL_ERROR
InitializeProcessCommandLine(
LPWSTR lpwstrCmdLine,
Expand All @@ -70,8 +33,6 @@ namespace CorUnix
CreateInitialProcessAndThreadObjects(
CPalThread *pThread
);

extern IPalObject *g_pobjProcess;
}

#endif // _PAL_PROCOBJ_HPP_
Expand Down
3 changes: 1 addition & 2 deletions src/coreclr/pal/src/init/pal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,8 @@ Initialize(

if (init_count == 0)
{
// Set our pid and sid.
// Set our pid.
gPID = getpid();
gSID = getsid(gPID);

// Initialize the thread local storage
if (FALSE == TLSInitialize())
Expand Down
Loading