This is the mail archive of the cygwin-developers mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

improve cygwin_attach_handle_to_fd()


Hi All.
There's undocumented function cygwin_attach_handle_to_fd() , which is
similar to Visual C _open_osfhandle() for wrapping Windows file handles.

I wanted to wrap a handle returned by CreateNamedPipe() using a custom
tool running in background and then dup the fd to parent shell using
exec 4</proc/$!/fd/4

I knew Cygwin internally used CreateNamedPipe() instead of CreatePipe()
and hoped the idea would work. Unfortunately it didn't, mainly because
cygwin_attach_handle_to_fd() calls some other windows functions on the
handle, which is fine for normal files, but makes a connected pipe unusable.

Also for stealing a pipe handle via procfs, the fd should have a special
name like "pipe:[652]". You cannot freely choose the name with
cygwin_attach_handle_to_fd()

Do you think it is possible to add another function for wrapping native
pipes and sockets? It could be less destructive for a hanlde, if it took
all the needed info from its parameters instead of querying the hanlde.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]