Module: wine Branch: master Commit: 3bf54c29500b9ca66e79c4877c87498e356b2975 URL: http://source.winehq.org/git/wine.git/?a=commit;h=3bf54c29500b9ca66e79c4877c...
Author: Marcus Meissner marcus@jet.franken.de Date: Sun Jan 13 21:55:29 2008 +0100
server: Enumerate process in reverse.
---
dlls/kernel32/tests/toolhelp.c | 7 ++++++- server/process.c | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/dlls/kernel32/tests/toolhelp.c b/dlls/kernel32/tests/toolhelp.c index 3ae7540..3249379 100644 --- a/dlls/kernel32/tests/toolhelp.c +++ b/dlls/kernel32/tests/toolhelp.c @@ -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");
diff --git a/server/process.c b/server/process.c index 2236d83..35740fe 100644 --- a/server/process.c +++ b/server/process.c @@ -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 ))) {