Changeset 420
- Timestamp:
- Dec 8, 2014, 3:25:53 AM (11 years ago)
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/branch-1-0/include/helpers/procstat.h
r206 r420 13 13 14 14 /* 15 * This file Copyright (C) 1992- 99Ulrich Mller,16 * Kai Uwe Rommel.15 * This file Copyright (C) 1992-2014 Ulrich Mller, 16 * Kai Uwe Rommel. 17 17 * This file is part of the "XWorkplace helpers" source package. 18 18 * This is free software; you can redistribute it and/or modify … … 234 234 235 235 // #pragma pack(1) 236 #pragma pack(4) // V0.9.10 (2001-04-08) [umoeller]237 236 238 237 #define QS32_PROCESS 0x0001 … … 276 275 { 277 276 ULONG ulThreadCount; // thread count 278 ULONG ulProcCount; // process count 277 // ULONG ulProcCount; // process count wrong V1.0.1 (2003-01-10) [umoeller] 278 ULONG ulSem32Count; // count of 32-bit sems? 279 279 ULONG ulModuleCount; // module count 280 280 } QGLOBAL32, *PQGLOBAL32; … … 806 806 ********************************************************************/ 807 807 808 PQTOPLEVEL32 prc32GetInfo2(ULONG fl, 809 APIRET *parc); 810 808 811 PQTOPLEVEL32 prc32GetInfo(APIRET *parc); 809 812 … … 830 833 PQFILEDATA32 prc32FindFileData(PQTOPLEVEL32 pInfo, 831 834 USHORT usFileID); 835 836 void prc32KillProcessTree(ULONG pid); 837 838 void prc32KillProcessTree2(PQPROCESS32 pProcThis, ULONG pid); 832 839 833 840 #endif -
branches/branch-1-0/src/helpers/procstat.c
r229 r420 33 33 /* 34 34 * Copyright (C) 1992-1994 Kai Uwe Rommel. 35 * Copyright (C) 1998-20 00Ulrich Mller.35 * Copyright (C) 1998-2014 Ulrich Mller. 36 36 * This file is part of the "XWorkplace helpers" source package. 37 37 * This is free software; you can redistribute it and/or modify … … 52 52 #define INCL_DOSMODULEMGR 53 53 #define INCL_DOSERRORS 54 #define INCL_DOSPROCESS 54 55 #include <os2.h> 55 56 … … 94 95 95 96 if (!ppps) 96 return (ERROR_INVALID_PARAMETER);97 return ERROR_INVALID_PARAMETER; 97 98 98 99 // changed allocation V0.9.10 (2001-04-08) [umoeller]: … … 187 188 } 188 189 189 return (pReturn);190 return pReturn; 190 191 } 191 192 … … 222 223 } 223 224 224 return (pReturn);225 return pReturn; 225 226 } 226 227 … … 300 301 } 301 302 302 return (rc);303 return rc; 303 304 } 304 305 … … 349 350 } 350 351 351 return (ulrc);352 return ulrc; 352 353 } 353 354 … … 394 395 } 395 396 396 return (ulrc);397 return ulrc; 397 398 } 398 399 … … 483 484 if (prc16QueryThreadInfo(pps, usPID, usTID, &prct)) 484 485 ulrc = prct.ulPriority; 485 return (ulrc);486 return ulrc; 486 487 } 487 488 … … 497 498 498 499 /* 500 *@@ prc32GetInfo2: 501 * nifty interface to DosQuerySysState, the 32-bit 502 * version of DosQProcStat. 503 * 504 * This returns the head of a newly allocated buffer 505 * which has plenty of pointers for subsequent browing. 506 * 507 * As opposed to prc32GetInfo, with this call you can 508 * specify the information that would like to retrieve. 509 * 510 * Use prc32FreeInfo to free the buffer. 511 * 512 *@@added V1.0.1 (2003-01-10) [umoeller] 513 */ 514 515 PQTOPLEVEL32 prc32GetInfo2(ULONG fl, // in: QS32_* flags 516 APIRET *parc) // out: error, ptr can be NULL 517 { 518 APIRET arc; 519 PQTOPLEVEL32 pReturn = NULL; 520 521 #define BUFSIZE (1024 * 1024) // 1 meg 522 523 if (!(arc = DosAllocMem((PVOID*)&pReturn, 524 BUFSIZE, 525 PAG_READ | PAG_WRITE | PAG_COMMIT | OBJ_TILE))) 526 { 527 if (arc = DosQuerySysState(fl, 528 fl, // this was missing V0.9.10 (2001-04-08) [umoeller] 529 0, 0, 530 (PCHAR)pReturn, 531 BUFSIZE)) 532 { 533 DosFreeMem(pReturn); 534 pReturn = NULL; 535 } 536 } 537 538 if (parc) 539 *parc = arc; 540 541 return pReturn; 542 } 543 544 /* 499 545 *@@ prc32GetInfo: 500 * nifty interface to DosQuerySysState, 501 * the 32-bitversion of DosQProcStat.502 * This returns the head of a newly503 * allocated buffer which has plenty504 * of pointers for subsequent browing.546 * nifty interface to DosQuerySysState, the 32-bit 547 * version of DosQProcStat. 548 * 549 * This returns the head of a newly allocated buffer 550 * which has plenty of pointers for subsequent browing. 505 551 * 506 552 * Use prc32FreeInfo to free the buffer. … … 513 559 PQTOPLEVEL32 prc32GetInfo(APIRET *parc) // out: error, ptr can be NULL 514 560 { 515 #define BUFSIZE (1024 * 1024) // 1 meg 516 517 PCHAR pBuf = NULL; // (PCHAR)malloc(BUFSIZE); 518 519 if (DosAllocMem((PVOID*)&pBuf, 520 BUFSIZE, 521 PAG_READ | PAG_WRITE | PAG_COMMIT | OBJ_TILE) 522 == NO_ERROR) 523 if (pBuf) 524 { 525 APIRET arc = DosQuerySysState(QS32_SUPPORTED, 526 QS32_SUPPORTED, // this was missing 527 // V0.9.10 (2001-04-08) [umoeller] 528 0, 0, 529 (PCHAR)pBuf, 530 BUFSIZE); 531 if (parc) 532 *parc = arc; 533 534 if (arc == NO_ERROR) 535 return ((PQTOPLEVEL32)pBuf); 536 else 537 DosFreeMem(pBuf); 538 } 539 540 return NULL; 561 return prc32GetInfo2(QS32_SUPPORTED, 562 parc); 541 563 } 542 564 … … 594 616 595 617 if (pProcThis->ulRecType == 1) 596 return (pProcThis);597 else 598 618 return pProcThis; 619 620 return NULL; 599 621 } 600 622 … … 649 671 { 650 672 if (i == usSemID) 651 return (pSemThis);673 return pSemThis; 652 674 653 675 i++; … … 678 700 { 679 701 if (pSemThis->usIndex == usSemID) 680 return (pSemThis);702 return pSemThis; 681 703 682 704 pSemThis = pSemThis->pNext; … … 704 726 { 705 727 if (pShrMem->usHandle == usShrMemID) 706 return (pShrMem);728 return pShrMem; 707 729 pShrMem = pShrMem->pNext; 708 730 } … … 759 781 { 760 782 if (pFile->paFiles[ul].usSFN == usFileID) 761 return (pFile);783 return pFile; 762 784 } 763 785 … … 768 790 } 769 791 770 792 /* 793 *@@ prc32KillProcessTree: 794 * 795 *@@added XWP V1.0.10 (2014-12-07) [pr] 796 */ 797 798 void 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 817 void 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 -
trunk/include/helpers/procstat.h
r257 r420 13 13 14 14 /* 15 * This file Copyright (C) 1992- 99Ulrich Mller,16 * Kai Uwe Rommel.15 * This file Copyright (C) 1992-2014 Ulrich Mller, 16 * Kai Uwe Rommel. 17 17 * This file is part of the "XWorkplace helpers" source package. 18 18 * This is free software; you can redistribute it and/or modify … … 834 834 USHORT usFileID); 835 835 836 void prc32KillProcessTree(ULONG pid); 837 838 void prc32KillProcessTree2(PQPROCESS32 pProcThis, ULONG pid); 839 836 840 #endif 837 841 -
trunk/src/helpers/procstat.c
r240 r420 33 33 /* 34 34 * Copyright (C) 1992-1994 Kai Uwe Rommel. 35 * Copyright (C) 1998-20 00Ulrich Mller.35 * Copyright (C) 1998-2014 Ulrich Mller. 36 36 * This file is part of the "XWorkplace helpers" source package. 37 37 * This is free software; you can redistribute it and/or modify … … 52 52 #define INCL_DOSMODULEMGR 53 53 #define INCL_DOSERRORS 54 #define INCL_DOSPROCESS 54 55 #include <os2.h> 55 56 … … 789 790 } 790 791 791 792 /* 793 *@@ prc32KillProcessTree: 794 * 795 *@@added XWP V1.0.10 (2014-12-07) [pr] 796 */ 797 798 void 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 817 void 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.