Commit 3bf54c29 authored by Marcus Meissner's avatar Marcus Meissner Committed by Alexandre Julliard

server: Enumerate process in reverse.

parent 83300893
......@@ -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");
......
......@@ -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 )))
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment