delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/05/23/20:35:38

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Date: Wed, 23 May 2001 19:25:40 -0400
From: Christopher Faylor <cgf AT redhat DOT com>
To: cygwin AT cygwin DOT com
Cc: nelson AT reversion DOT ca
Subject: Re: cygwin_attach_handle_to_fd()
Message-ID: <20010523192540.A15862@redhat.com>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com, nelson AT reversion DOT ca
References: <3B0C35D4 DOT 5B3849D0 AT reversion DOT ca>
Mime-Version: 1.0
User-Agent: Mutt/1.3.11i
In-Reply-To: <3B0C35D4.5B3849D0@reversion.ca>; from nelson@reversion.ca on Wed, May 23, 2001 at 04:12:36PM -0600

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 AT reversion DOT 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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019