This is the mail archive of the cygwin@cygwin.com 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]

Re: cygwin_attach_handle_to_fd()


On Wed, May 23, 2001 at 04:12:36PM -0600, Craig Nelson wrote:
>Hi All, just looking for a bit more info on
>cygwin_attach_handle_to_fd(): the API references shows it as:
>
>----snip----
>extern "C" int cygwin_attach_handle_to_fd(char *name, int fd, HANDLE handle, int bin, int access);
>
>This function can be used to turn a Win32 "handle" into a posix-style
>file handle.  fd may be -1 to make cygwin allocate a handle; the actual
>handle is returned in all cases.
>
>----snip----
>
>But I'm wondering what kinds of values BIN, ACCESS, and NAME are expected to have.  In particular:
>
>    -Does NAME have to be a unique string?  if so, unique amongst each invocation of a cygwin process, etc.
>    -Should BIN be set to unix things like O_BINARY | O_RDONLY or win32 things like GENERIC_READ, etc.
>    -Should ACCESS be set to unix things like S_IRWXU or win32 things like FILE_SHARE_READ, etc.
>
>Any help on all the options for this function would be greatly appreciated.

>From inspecting the code:
'name' is the name of the file or device.
'bin' is true if the file should be opened in binary mode, false for text mode.
'access' is a windows setting like 'GENERIC_READ' or 'GENERIC-WRITE'.

>Incase anybody is wondering why I'm needing this: The reason is, I'm
>using CreateProcess(), CreatePipe() and cygwin_attach_handle_to_fd() in
>order to start up a child process and redirect its STDIN, STDOUT, and
>STDERR and use it in my program.  It works great except the fd returned
>from attach_handle() appears to never get closed (and therfore read()
>blocks indefinately because it never gets an EOF).

It sounds like you're reinventing "popen" to me.

>I've tried setting BIN and ACCESS to constants shown above (without
>success), and I am wondering If there's something I've not set.  I'm
>running NT4sp6a with the latest cygwin-1.3.2 release.  please send a
>reply to nelson@reversion.ca (and the list, if desired)

Probably the best thing you could do is inspect the source code.  That's
what I just did.

cgf

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple


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