1
0
mirror of https://github.com/wine-mirror/wine synced 2024-07-05 17:28:47 +00:00

server: Enumerate process in reverse.

This commit is contained in:
Marcus Meissner 2008-01-13 21:55:29 +01:00 committed by Alexandre Julliard
parent 83300893a2
commit 3bf54c2950
2 changed files with 7 additions and 2 deletions

View File

@ -106,6 +106,7 @@ static void test_process(DWORD curr_pid, DWORD sub_pcs_pid)
MODULEENTRY32 me;
unsigned found = 0;
int num = 0;
int childpos = -1;
hSnapshot = pCreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
ok(hSnapshot != NULL, "Cannot create snapshot\n");
@ -117,7 +118,7 @@ static void test_process(DWORD curr_pid, DWORD sub_pcs_pid)
do
{
if (pe.th32ProcessID == curr_pid) found++;
if (pe.th32ProcessID == sub_pcs_pid) found++;
if (pe.th32ProcessID == sub_pcs_pid) { childpos = num; found++; }
trace("PID=%x %s\n", pe.th32ProcessID, pe.szExeFile);
num++;
} while (pProcess32Next( hSnapshot, &pe ));
@ -139,6 +140,10 @@ static void test_process(DWORD curr_pid, DWORD sub_pcs_pid)
ok(found == 2, "couldn't find self and/or sub-process in process list\n");
ok(!num, "mismatch in counting\n");
/* one broken program does Process32First() and does not expect anything
* interesting to be there, especially not the just forked off child */
ok (childpos !=0, "child is not expected to be at position 0.\n");
te.dwSize = sizeof(te);
ok(!pThread32First( hSnapshot, &te ), "shouldn't return a thread\n");

View File

@ -344,7 +344,7 @@ struct thread *create_process( int fd, struct thread *parent_thread, int inherit
process->start_time = current_time;
process->end_time = 0;
list_add_head( &process_list, &process->entry );
list_add_tail( &process_list, &process->entry );
if (!(process->id = process->group_id = alloc_ptid( process )))
{