[comp.os.msdos.programmer] Restoring system state

joefritz@pawl.rpi.edu (Jochen M. Fritz) (11/14/90)

I am writing a piece of software that requires that I spawn a subtask,
then when it returns to undo ANYTHING that this subtask did to the system.
ie,  Kill any loaded tsr's, release any memory, reset the video mode (trivial)
restore the interrupt table, etc.  The subtask can exit in two ways:
(1) Quit    or
(2) Generate an interrupt that will terminate the task.


For (1), it is simply a matter of restoring the int table, and finding and
freeing memory that is no longer in use.

For (2), the program must close all files, kill both the tsrs and the 
subtask, SWITCH PID BACK TO THE ORIGINAL.

Since this requires wading neck-deep in the internal MS-DOS system calls,
I do not have complete confidence in what I need to do the acheave this.
Therefore, my question is:  If the above complete and correct, and how
do I set the pid?  Also, will the free block functions work on blocks that
the current task does not own?  And how can I safely kill a subtask so that
DOS is not completely confused.

I do have RB's interrupt list, and I have studied the source code for the 
mark/release utilities.  Undocumented calls are OK, but if possible it should 
be able to run in all standard real mode DOS environments (ie no windows,
or protected mode if it will run here, great, but it need not).

psudo code:

      save                 ;save the system state
      mv   intvect,intexit ;claim the exit interrupt
      exec  subtask        ;run the subtask
intexit:
      restore              ;restore all the stuff


Thanks for any help.
------------------------------------------------------------------------
| Jochen Fritz            | For though we live in the world, we do not |
| joefritz@pawl.rpi.edu   | wage war as the world does.-- 2 Cor. 10:3  |      
| usergk2s@rpitsmts.bitnet| You have heard it said, Love your neighbor |
| Noah [the peace monger] | and hate your enemy.  But I tell you: Love |
|                         | your enemies.  Matt. 5:43-44               |
------------------------------------------------------------------------