Mark Dootson wrote on 2011-07-22:
> Hi,
> 
> In CRT versions greater than Server 2003, the close() function checks
> its parameters. It expects a valid file descriptor ( the param check
> definition seems to say that an int is expected which should be a valid
> file descriptor.)
> 
> So, the int / file descriptor we pass to close() is being interpreted as
> invalid.
> 
> On older crts, there is no param check - so close proceeds and returns
> -1 if it fails.
> 
> But on new CRTs, the param is checked first, and if invalid, the
> standard invalid parameter handler is called. This default handler exits
> the application.  It seems utter nonesense that by default close() can
> never return -1. But that's how it seems to be.
> 
> see http://msdn.microsoft.com/en-us/library/5fzwd5ss.aspx
> 
> You can also look at the Server 2003 version from that page which
> indicates close() simply returns -1 if it does not succeed.
> 
> My current workaround is in the attached patch which makes build.c
> rather ugly. I do nothing in my custom invalid parameter handler leaving
> close() to behave as in earlier CRTs.
> 

Is there somewhere during initialization that the handler could be installed 
permanently instead of repeatedly installing/uninstalling it in my_close(). 
Perl itself installs an almost empty invalid parameter handler in 
Perl_win32_init(): see win32/win32.c.

Reply via email to