Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.jpl.nasa.gov (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: better version of chat2.pl Message-ID: <1991Apr12.070917.3248@jpl-devvax.jpl.nasa.gov> Date: 12 Apr 91 07:09:17 GMT References: <1991Apr11.222343.28800@iwarp.intel.com> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 20 In article <1991Apr11.222343.28800@iwarp.intel.com> merlyn@iwarp.intel.com (Randal L. Schwartz) writes: : Argh. Had some problems with filehandles not being closed. Hmm. : Larry, is it a bug that a failed connect() leaves a filehandle open, : and I have to close the handle (even though the close generates an : error)? Or is that just the way the underlying system works? (To : test this, I'd have to *gasp* code in C! :-) If the OS doesn't close a socket on connect failure, neither should Perl. (It doesn't.) You're probably getting the failure on close because there are two stdio streams bound to a single socket (stdio gets confused on some machines otherwise). Only the first fclose() can actually close the fd, so the second one gets an error. That should probably be suppressed. In fact, looking at the code, it seems to me that close shouldn't be returning an error on that, even though $! gets set. You aren't relying on $! without checking the return value, are you? The do_close() routine returns the value from the first fclose(), not the second. Or are you perhaps using an older version that returned the value of the second fclose()? Larry