www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/1998/05/26/17:35:13

From: cgf AT cygnus DOT com (Christopher Faylor)
Subject: Re: close-on-exec doesnt work for spawn*()
26 May 1998 17:35:13 -0700 :
Message-ID: <199805262350.TAA28900.cygnus.cygwin32.developers@kramden.cygnus.com>
To: cygwin32-developers AT cygnus DOT com

>From: newsham AT lava DOT net (Tim Newsham)
>Date: Tue, 26 May 1998 13:16:34 -1000 (HST)
>
>> close_on_exec is only called for P_OVERLAY spawn, i.e. exec().
>> Whether this is correct or not is debatable, I think.
>
>Ok,  I'll start the debate :)
>
>    - If I set close-on-exec flag on a descriptor, that descriptor
>      should not be open in any other (non-fork'ed) processes
>      created by the program.
>
>Is there any other mechanism for making file descriptors close when
>a spawn is performed?

The problem is that the current implementation of close_on_exec actually
closes the files in the process prior to executing the exec.  That
doesn't work well with P_NOWAIT.

An alternate way of doing this would be to have the delinearize function
close files as it is... delinearizing them.  That would have the advantage
of doing what you want but it would have the disadvantage of only working
with cygwin32 programs specifically.

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.

The bottom line is that I don't think there is any foolproof way to do this.

cgf

- Raw text -


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