This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Do not open Python scripts twice #2 [Re: [RFC] Crash sourcing Python script on Windows]


Does anyone know if there's a way to create a PyFile from an open Windows
file HANDLE (that is, an hypothetical PyFile_from_HANDLE function)?

If there is, we could do something like:

 static PyObject *
 PyFile_from_FILE (FILE *file, const char *filename, char *mode)
 {
 #ifdef _WIN32
   HANDLE h = _get_osfhandle (fileno (file));
   return PyFile_from_HANDLE (h, ...);
 #else
   return PyFile_FromFile(file, filename, mode, ...);
 }

Unlike libc objects, HANDLEs are common to all loaded libcs, given
that they live in the common Win32/NT layer beneath libc, so that
would work around the multiple libc's problem, and, would plug the
race on Windows too.

_get_osfhandle:
http://msdn.microsoft.com/en-us/library/ks2530z6.aspx

-- 
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]