Ignore:
Timestamp:
Dec 8, 2014, 3:25:53 AM (11 years ago)
Author:
pr
Message:

Add prc32KillProcessTree.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/procstat.c

    r240 r420  
    3333/*
    3434 *      Copyright (C) 1992-1994 Kai Uwe Rommel.
    35  *      Copyright (C) 1998-2000 Ulrich M”ller.
     35 *      Copyright (C) 1998-2014 Ulrich M”ller.
    3636 *      This file is part of the "XWorkplace helpers" source package.
    3737 *      This is free software; you can redistribute it and/or modify
     
    5252#define INCL_DOSMODULEMGR
    5353#define INCL_DOSERRORS
     54#define INCL_DOSPROCESS
    5455#include <os2.h>
    5556
     
    789790}
    790791
    791 
     792/*
     793 *@@ prc32KillProcessTree:
     794 *
     795 *@@added XWP V1.0.10 (2014-12-07) [pr]
     796 */
     797
     798void prc32KillProcessTree(ULONG pid)
     799{
     800    APIRET arc;
     801    PQTOPLEVEL32 pInfo = prc32GetInfo2(QS32_PROCESS, &arc);
     802
     803    if (arc == NO_ERROR)
     804    {
     805        prc32KillProcessTree2(pInfo->pProcessData, pid);
     806        DosKillProcess(DKP_PROCESS, pid);
     807        prc32FreeInfo(pInfo);
     808    }
     809}
     810
     811/*
     812 *@@ prc32KillProcessTree2:
     813 *
     814 *@@added XWP V1.0.10 (2014-12-07) [pr]
     815 */
     816
     817void prc32KillProcessTree2(PQPROCESS32 pProcThis, ULONG pid)
     818{
     819    while (pProcThis && pProcThis->ulRecType == 1)
     820    {
     821        PQTHREAD32 t = pProcThis->pThreads;
     822
     823        if (pProcThis->usPPID == pid)
     824        {
     825            prc32KillProcessTree2(pProcThis, pProcThis->usPID);
     826            DosKillProcess(DKP_PROCESS, pProcThis->usPID);
     827        }
     828
     829        // for next process, skip the threads info;
     830        // the next process block comes after the threads
     831        t += pProcThis->usThreadCount;
     832        pProcThis = (PQPROCESS32)t;
     833    }
     834}
     835
Note: See TracChangeset for help on using the changeset viewer.