delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/1998/05/28/05:12:21

From: cgf AT cygnus DOT com (Christopher Faylor)
Subject: RE: close-on-exec doesnt work for spawn*()
28 May 1998 05:12:21 -0700 :
Message-ID: <199805281158.HAA30827.cygnus.cygwin32.developers@kramden.cygnus.com>
To: sos AT prospect DOT com DOT ru
Cc: cygwin32-developers AT cygnus DOT com

>From: Sergey Okhapkin <sos AT prospect DOT com DOT ru>
>Date: Thu, 28 May 1998 10:12:54 +0400
>
>Tim Newsham wrote:
>>> There is also a SetHandle function that would do this on a Win32
>>basis, but > I believe it is only available for NT 4 and beyond.
>>
>>On a related note:
>>
>>     Is there any way to get a hold of a handle given the unix-type
>>     file descriptor in cygwin?
>>
>
>The only way I know now is
>
>handle=get_osfhandle(fd); SetHandleInformation(handle,...);
>
>But this works on NT only - W95 doesn't support SetHandleInformation()
>call.  The good solution I see in new fcntl call:
>
>fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONINHERIT);
>
>On this call fcntl() should duplicate original fd's handle to
>non-inherittable, close original handle and set_handle() to duplicated.

That's the call I was thinking of.  There is a problem with using it,
however, given cygwin32's fork implementation.  It will essentially
be close on fork/exec.
--
cgf AT cygnus DOT com             "Everything has a boolean value, if you stand
http://www.cygnus.com/      far enough away from it."  -- Galena Alyson Canada

- Raw text -


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