Re: Problem with locked files - solved (inheritable handles)

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Tom Stewart (tastewar_at_newsgroups.nospam)
Date: 06/11/04


Date: Fri, 11 Jun 2004 09:43:18 -0400

Sorry, Don, but you are missing the most important point, which in my view is how one might solve Dylan's specific
problem. I *do* understand how handles work. If you look more carefully at my suggestion, all it does is change what's
passed in to CreateFile on a per-thread basis. I didn't make any claim about a thread association of handles. If you
also look back at the original post, Dylan states, "The secondary process does need to inherit some handles (because I
redirect its input and output), but it certainly shouldn't be inheriting every single file handle opened by the process,
and specifically not those from other threads." Seems to me that in his design (and likely many others) that while
threads are indeed *valid* throughout a process, that in practice they are often *used* only by a particular thread. I
still think that my suggested change to the crt would accomodate Dylan's design. Specifically, the thread that he uses
to create child processes would create inheritable handles. The other threads would create non-inheritable handles via
the proposed function call. Remember, he's already implemented an effective workaround at the application level, it's
just that it was uglier than he wanted and required him to delve into Win32 to call CreateFile directly, which
apparently he preferred not to. I was only offering that a cleaner workaround could be implemented in the library, and
only as an intellectual exercise really.

--
Tom
"Don Burn" <burn@stopspam.acm.org> wrote in message news:10cj9ifd9m5lla2@corp.supernews.com...
>
> "Tom Stewart" <tastewar@newsgroups.nospam> wrote in message
> news:elYWR26TEHA.3140@tk2msftngp13.phx.gbl...
> > Sorry, but impossible is a very strong word, esp. in the world of
> software.
> >
> > Seems to me the CRT could be changed pretty trivially to accomplish this
> in a backward compatible manner. Scheme goes
> > something like this:
> >
> > New CRT function:
> >
> > MicrosoftSpecificCRTSetThreadPrefs ( DISALLOW_HANDLE_INHERITANCE, TRUE );
> >
> > This would set a thread specific flag, internal to the CRT that would be
> taken into account in all CreateFile calls. If
> > you don't set the flag, the function behaves as it always did. Dylan would
> call this (if his code is intended  to be
> > platform neutral, it would be in some ifdef block) for all threads other
> than the one which creates child processes.
> >
> > Am I missing something? I'm not suggesting that they'd actually be willing
> to *do* this, or even that it would
> > necessarily be useful outside of Dylan's design, but it doesn't seem that
> hard.
>
>
> Yes you are missing the most important point.  Handles are stored on a per
> process basis!  There is absolutely no association of a thread and a handle,
> only a process and a handle.  Changing this would impact the OS, break many
> programs, and even break a reasonable number of device drivers.
>
>
> -- 
> Don Burn (MVP, Windows DDK)
> Windows 2k/XP/2k3 Filesystem and Driver Consulting
> Remove StopSpam from the email to reply
>
>


Relevant Pages

  • Re: Why cant I display a bitmap I create?
    ... scenario I mentioned earlier and which doesn't seem to apply to your ... told you to use that design. ... Graphics object passed to you in the PaintEventArgs object. ... The only thing that would be missing is the AppIdle event from ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: A missing-data problem
    ... measures design with a dichotomous dependent variable measured twice, ... and suppose that one measure is missing for some cases. ... a reference to a paper on the continuous-d.v. ... There are design problems if the results are not ...
    (sci.stat.math)
  • Re: Read Only Users
    ... > No, Dan, you're not missing anything. ... > MS will change the design. ... When they try to save it brings up a windows logon box asking ...
    (microsoft.public.sharepoint.portalserver)
  • Re: unable to find platform.bib
    ... just copy the file from the BSP. ... this occurs early in the creation of your OS design. ... prevent it's pre-processing and results in a missing output file. ... (l'indirizzo di reply di questo messaggio non è ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Norvig on Lisp vs Python revised
    ... > be similarly missing things for Python but not knowing the language I ... design and evolution of a programming language. ... various versions of the HOPL-2 paper (well over a dozen reviews) was ...
    (comp.lang.lisp)