Ignore:
Timestamp:
Jul 26, 2002, 12:47:59 PM (23 years ago)
Author:
sandervl
Message:

terminate & resume threads that are suspended when ExitProcess is called

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/wprocess.cpp

    r8773 r8921  
    1 /* $Id: wprocess.cpp,v 1.156 2002-06-26 07:13:00 sandervl Exp $ */
     1/* $Id: wprocess.cpp,v 1.157 2002-07-26 10:47:59 sandervl Exp $ */
    22
    33/*
     
    465465VOID WIN32API ExitProcess(DWORD exitcode)
    466466{
     467    HANDLE hThread = GetCurrentThread();
     468    TEB   *teb;
     469
    467470    dprintf(("KERNEL32:  ExitProcess %d\n", exitcode));
    468471    dprintf(("KERNEL32:  ExitProcess FS = %x\n", GetFS()));
     
    473476
    474477    HMDeviceCommClass::CloseOverlappedIOHandlers();
     478
     479    //detach all dlls (LIFO order) before really unloading them; this
     480    //should take care of circular dependencies (crash while accessing
     481    //memory of a dll that has just been freed)
     482    dprintf(("********************************************"));
     483    dprintf(("**** Detach process from all dlls -- START"));
     484    Win32DllBase::detachProcessFromAllDlls();
     485    dprintf(("**** Detach process from all dlls -- END"));
     486    dprintf(("********************************************"));
    475487
    476488    if(WinExe) {
     
    485497    //SvL: We must make sure no threads are still suspended (with SuspendThread)
    486498    //     OS/2 seems to be unable to terminate the process otherwise (exitlist hang)
    487     TEB *teb = threadList;
    488499    threadListMutex.enter();
     500    teb = threadList;
    489501    while(teb) {
    490         ResumeThread(teb->o.odin.hThread);
     502        if(teb->o.odin.hThread != hThread && teb->o.odin.dwSuspend > 0) {
     503            //kill any threads that are suspended; dangerous, but so is calling
     504            //SuspendThread; we assume the app knew what it was doing
     505            TerminateThread(teb->o.odin.hThread, 0);
     506            ResumeThread(teb->o.odin.hThread);
     507        }
    491508        teb = teb->o.odin.next;
    492509    }
    493510    threadListMutex.leave();
    494 
    495511
    496512#ifdef PROFILE
Note: See TracChangeset for help on using the changeset viewer.