DuplicateHandle() question

egor duda deo@logos-m.ru
Wed Jun 12 08:46:00 GMT 2002


Wednesday, 12 June, 2002 Conrad Scott Conrad.Scott@dsl.pipex.com wrote:

CS> [I hope this is sufficiently on-topic for this list.]

CS> I'm looking at the cygserver shm implementation and I've got a Win32 issue
CS> that I wondered if anyone out there might be able to help me with.

CS> The problem is that the server uses DuplicateHandle() to create a handle in
CS> the client process. Then if the server later decides to abort the operation,

It'd be late to decide. Being a server doesn't make it so important to
decide for other process what to do with its handles.

CS> how can it close that child handle? Or can't it? If it can't, the server
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 handle
CS> along with the error response).

CS> Any thoughts? or am I misunderstanding some deep fact about Win32 handles?

Win32 handles are pretty similar to unix descriptors. if some process
duplicates an fd and pass it, say, to child, it has no control of what
child will do with his fds.

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?

Egor.            mailto:deo@logos-m.ru ICQ 5165414 FidoNet 2:5020/496.19

More information about the Cygwin-developers mailing list