TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Paul Edwards
from: Jonathan de Boyne Pollard
date: 1996-12-06 09:14:16
subject: File Handles

PE>
  > JdeBP> For another, even if the device driver *could* make
  > JdeBP> application-level API calls to perform file I/O, there's no
  > JdeBP> guarantee that the process, one of its parents, will not have
  > JdeBP> closed the file handle concerned an possibly opened another one
  > JdeBP> in its stead.  There are no "system" or
"reserved" file handles.
  > JdeBP> Each process is sovereign as far as its ope file handles are
  > JdeBP> concerned.
  >
  > But I don't agree with this.  You don't have the right to close arbitrary
  > file handles.  You're only allowed to close files that you
  > yourself have opened.  That's a bit like saying that the
  > device driver shouldn't rely on being able to access memory
  > it just malloc'ed, because "the user might have run a
  > program to go and deliberately clobber that memory".
PE>

  Wrong on both counts.

  First count :  An OS/2 process can do what it likes with *any* of the
  file handles that it has open.  There's *nothing* that stops it from
  closing any or all file handles that it has open.  As far as its file
  handle table is concerned, each process is sovereign.

  Ever written a daemon process ?  What's the first thing that a
  well-written background daemon process does ?  That's right.  It closes
  any open file handles that it may have accidentally inherited.

  Second count :  Memory allocated by a device driver is allocated from
  kernel space, using special Device Help APIs provided specifically for
  that purpose, and is "owned" by the driver itself.  The memory is not a
  application-level resource.  File handles opened by a device driver in
  its INIT processing, on the other hand, *are* application-level
  resources, are managed by application-level APIs, and belong to process
  0, not the device driver.

  So whereas a device driver can allocate and free kernel-level memory at
  any point (as long as it does it in its upper half), because that memory
  does not belong to the process that the driver code happens to be
  currently executing in, it cannot open, use, and close file handles,
  because they *do* belong to the currently executing process.

PE>
  > BTW, if you see a message from me at 5AM, it's NOT because
  > I'm an earlybird.  :-)
PE>

  Why is it then ?  (-:

  > JdeBP <
___
 X MegaMail 2.10 #0:
--- Maximus/2 3.01
* Origin: DoNoR/2,Woking UK (44-1483-725167) (2:440/4)
SEEN-BY: 50/99 270/101 620/243 625/160 711/401 409 410 413 430 808 809 934
SEEN-BY: 711/955 712/407 515 624 628 713/317 800/1
@PATH: 440/4 141/209 270/101 712/515 711/808 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.