Update contrib.
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
26 #include <sys/errno.h>
33 // simple function so the parent can wait for child and test waitpid
40 @SYMTestCaseID SYSLIB-STDLIB-UT-1576
41 @SYMTestCaseDesc Testing if POSIX waitpid function conforms to POSIX standard
43 @SYMTestActions Starts a new processes and tests the POSIX waitpid function with
44 different parameters and checks if it behaves correctly
45 @SYMTestExpectedResults The test should not fail.
56 test_Title("WAITPID");
58 proc = create_process(doafunc, "A", "rw", fids);
62 perror("Failed to start process A: ");
64 // test return values of calls to waitpid with different options and pid's
68 // test with option WNOHANG and a correct pid on an active process
69 ret = wait_for_process_id(proc,get_proc_id(proc),WNOHANG,&status);
71 // test with an invalid pid
72 ret = wait_for_process_id(proc,99,0,&status);
73 test(errno==ECHILD&&ret==-1);
74 // test with invalid options
75 ret = wait_for_process_id(proc,99,17,&status);
76 test(errno==EINVAL&&ret==-1);
77 ret = wait_for_process_id(proc,99,18,&status);
78 test(errno==EINVAL&&ret==-1);
79 // process is still active keep waiting until it dies
82 ret = wait_for_process_id(proc,get_proc_id(proc),WNOHANG,&status);
84 while(!WIFEXITED(status)&&ret==0);
85 test(ret==get_proc_id(proc));
86 printf("child exited, status=%d\n", WEXITSTATUS(status));
89 // create another process and test waitpid with pid -1 and options 0
90 // this is the same as calling wait
91 proc2 = create_process(doafunc, "B", "rw", fids);
95 perror("Failed to start process B: ");
98 //wait for proc2 to finish
101 ret = wait_for_process_id(proc2,-1,0,&status);
103 while (!WIFEXITED(status));
104 test(ret==get_proc_id(proc2));
105 printf("child exited, status=%d\n", WEXITSTATUS(status));
116 int main (int argc, char *argv[])
119 start_redirection_server();
121 //do something with child process
125 // exit here for the moment crt0 libraries panic