delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/1998/05/27/23:15:44

From: sos AT prospect DOT com DOT ru (Sergey Okhapkin)
Subject: RE: close-on-exec doesnt work for spawn*()
27 May 1998 23:15:44 -0700 :
Message-ID: <01BD8A21.2E54DFB0.cygnus.cygwin32.developers@drs>
Cc: "cygwin32-developers AT cygnus DOT com" <cygwin32-developers AT cygnus DOT com>

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.

-- 
Sergey Okhapkin, http://www.lexa.ru/sos
Moscow, Russia.

- Raw text -


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