DuplicateHandle() question

Conrad Scott Conrad.Scott@dsl.pipex.com
Wed Jun 12 10:10:00 GMT 2002


Thanks for the reply.

"egor duda" <deo@logos-m.ru> wrote:
> Hi!
> Conrad Scott Conrad.Scott@dsl.pipex.com wrote:
> CS> how can it close that child handle? Or can't it? If it can't, the
> CS> will have to arrange for the client to close it for itself, which
makes the
> CS> error handling all the more complex (i.e. send back the offending
> CS> along with the error response).
> I don't quite understand why server would want client to discard some
> handle. Can you describe step-by-step scenario when it's needed? Do
> you have shmctl(..., IPC_RMID, ...) in mind?

Not shmctl(2) but shmget(2): when creating and accessing shm segments for a
client, the cygserver calls CreateFileMapping() to create the memory areas
and then uses DuplicateHandle() on the resulting handles to create handles
for the client (in client process) to these file mappings. The problem then
arises that the sever can fail having duplicated some but not all of the
handles for the client, i.e. it's just an error cleanup question: I'm not
looking to have the server arbitrarily close client handles.

AIUI at that point the handles are valid in the client process but the
server can't close them, i.e. the client has to close them. Is that true or
is there some way for the server to close them (i.e. a "close in other
process" function)? I assume not.

Does that all make more sense?

// Conrad

p.s. I'm also assuming that trying to get the client to do the duplication
is going to run into security issues, as that would solve the issue

More information about the Cygwin-developers mailing list