Fixed descriptors not being reset by SysExit.

Indirectly, this fixes the snake; snake; panic bug.
This commit is contained in:
Jonas 'Sortie' Termansen 2011-11-22 19:12:04 +01:00
parent e234e0a2d4
commit b15763b2de
3 changed files with 12 additions and 11 deletions

View File

@ -42,15 +42,22 @@ namespace Sortix
}
DescriptorTable::~DescriptorTable()
{
Reset();
}
void DescriptorTable::Reset()
{
for ( int i = 0; i < numdevices; i++ )
{
if ( devices[i] == NULL || devices[i] == reserveddevideptr ) { continue; }
// TODO: unref any device here!
devices[i]->Unref();
}
delete[] devices;
devices = NULL;
numdevices = 0;
}
int DescriptorTable::Allocate(Device* object)

View File

@ -45,10 +45,12 @@ namespace Sortix
void Free(int index);
void UseReservation(int index, Device* object);
bool Fork(DescriptorTable* forkinto);
void Reset();
public:
inline Device* Get(int index)
{
if ( !devices ) { return NULL; }
if ( index < 0 || numdevices <= index ) { return NULL; }
return devices[index];
}

View File

@ -256,15 +256,6 @@ namespace Sortix
// TODO: Delete all threads and their stacks.
ResetAddressSpace();
// HACK: Don't let VGA buffers survive executes.
// Real Solution: Don't use VGA buffers in this manner.
for ( int i = 0; i < 32; i++ )
{
Device* dev = descriptors.Get(i);
if ( !dev ) { continue; }
if ( dev->IsType(Device::VGABUFFER) ) { descriptors.Free(i); }
}
}
int Process::Execute(const char* programname, const byte* program, size_t programsize, int argc, const char* const* argv, CPU::InterruptRegisters* regs)
@ -572,7 +563,8 @@ namespace Sortix
nextsibling->prevsibling = prevsibling;
}
// TODO: Close all the file descriptors!
// Close all the file descriptors.
descriptors.Reset();
// Make all threads belonging to process unrunnable.
for ( Thread* t = firstthread; t; t = t->nextsibling )