Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-developers-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin-developers AT sourceware DOT cygnus DOT com From: Chris Faylor Date: Mon, 17 Apr 2000 20:34:20 -0400 To: "'cygwin-developers AT sourceware DOT cygnus DOT com'" Subject: Re: sockets and close-on-exec (F_SETFD) Message-ID: <20000417203419.A4858@cygnus.com> Reply-To: cygwin-developers AT sourceware DOT cygnus DOT com Mail-Followup-To: cgf AT cygnus DOT com, "'cygwin-developers AT sourceware DOT cygnus DOT com'" References: <779F20BCCE5AD31186A50008C75D9979171716 AT SILLDN_MAIL1> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.1.8i In-Reply-To: <779F20BCCE5AD31186A50008C75D9979171716@SILLDN_MAIL1>; from EFifer@sanwaint.com on Mon, Apr 17, 2000 at 03:58:48PM +0100 On Mon, Apr 17, 2000 at 03:58:48PM +0100, Fifer, Eric wrote: >>Do you want to submit a patch? > >Below is what I did, but it's a little ugly because set_inheritance >is not a fhandler_base method and I stuck cygwin_closesocket in >net.cc because it already defines Win32_Winsock and I didn't want to >introduce that to fhandler.cc ... Hmm. I think you're right though. set_inheritance should be a fhandler* method. I was debating doing that when I wrote it but I didn't see a need for it. Now I do. Does this make sense? It's still a little bogus since the hclose method does not actually take an argument in the case of a socket but that's theoretically ok. It may be a future gotcha, though... cgf Index: fhandler.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/fhandler.cc,v retrieving revision 1.12 diff -u -p -r1.12 fhandler.cc --- fhandler.cc 2000/04/08 04:47:15 1.12 +++ fhandler.cc 2000/04/18 00:32:55 @@ -1427,8 +1427,8 @@ fhandler_pipe::lseek (off_t offset, int return -1; } -void __stdcall -set_inheritance (HANDLE &h, int not_inheriting, const char *name) +void +fhandler_base::set_inheritance (HANDLE &h, int not_inheriting, const char *name) { HANDLE newh; @@ -1438,16 +1438,17 @@ set_inheritance (HANDLE &h, int not_inhe #ifndef DEBUGGING else { - CloseHandle (h); + hclose (h); h = newh; } #else else if (!name) { - CloseHandle (h); + hclose (h); h = newh; } else + /* FIXME: This won't work with sockets */ { ForceCloseHandle2 (h, name); h = newh; Index: fhandler.h =================================================================== RCS file: /cvs/src/src/winsup/cygwin/fhandler.h,v retrieving revision 1.7 diff -u -p -r1.7 fhandler.h --- fhandler.h 2000/04/03 18:15:01 1.7 +++ fhandler.h 2000/04/18 00:32:55 @@ -235,6 +235,8 @@ public: const char *get_win32_name () { return win32_path_name_; } unsigned long get_namehash () { return namehash_; } + virtual void hclose (HANDLE h) {CloseHandle (h);} + virtual void set_inheritance (HANDLE &h, int not_inheriting, const char *name = NULL); /* fixup fd possibly non-inherited handles after fork */ void fork_fixup (HANDLE parent, HANDLE &h, const char *name); @@ -315,6 +317,7 @@ public: int ioctl (unsigned int cmd, void *); off_t lseek (off_t, int) { return 0; } int close (); + void hclose (HANDLE) {close ();} select_record *select_read (select_record *s); select_record *select_write (select_record *s); @@ -809,7 +812,5 @@ public: uid_t __stdcall get_file_owner (int, const char *); gid_t __stdcall get_file_group (int, const char *); - -void __stdcall set_inheritance (HANDLE &h, int val, const char *name = NULL); #endif /* _FHANDLER_H_ */