1 Jan 2007 02:22
Re: Windows equivalent of a specific fcntl call
Vincent Torri wrote: > I would like to translate that call: > > fcntl(fd, F_SETFD, FD_CLOEXEC); > > fd being the file descriptor. I've searched with google (for example: > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnucmg/html/UCMGch09.asp) > and in the mingw ML, but I didn't find any answer to that specific call. > > Can someone see what I should use ? On unix, exec*() means to replace the current process with a new process, but keeping the same PID, CWD, environment, uid, gid, process group membership, handles, et cetera. No such concept exists on Windows, so the _exec*() family of functions that are in MSVCRT are really just wrappers around calling CreateProcess() followed by _exit(), i.e. create a child process and then terminate the calling process. When a process terminates the OS forcibly reclaims all its resources, including closing all open handles. There is nothing you can do about this, as its one of those operating system principles that you have no control over, otherwise system stability would be dependant on every process cleaning itself up, and we all saw how well that worked with Windows 3.x. The only thing you can control is whether the child process is given a duplicate copy of any handles in the parent that were marked as inheritable. This is controlled in an all-or-nothing manner by the boolean fifth parameter to CreateProcess() and on a per-handle basis by(Continue reading)
Regards,
Keith.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
RSS Feed