oops - mmakefile changes had been reverted, so reinstate them.
[AROS.git] / test / exec / childstatus.c
blobb57e46423ea493ef1ec5408e5ff406edca14667c
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <proto/exec.h>
7 #include <dos/dosextens.h>
8 #include <proto/dos.h>
9 #include <assert.h>
11 LONG entry()
13 Delay(50);
14 return 0;
17 int main()
19 struct Process *child;
21 struct TagItem tags[] =
23 { NP_Entry, (IPTR) entry },
24 { NP_Cli, (IPTR) TRUE },
25 { NP_Name, (IPTR) "test" },
26 { NP_NotifyOnDeath, (IPTR) TRUE },
27 { TAG_DONE, 0 }
30 child = CreateNewProc(tags);
32 if(child)
34 ULONG childstatus;
35 ULONG childid = GetETask((struct Task*) child)->et_UniqueID;
36 Printf("Checking status value for non-existing child id\n");
37 childstatus = ChildStatus(-1);
38 assert(childstatus == CHILD_NOTFOUND);
39 Printf("Result: CHILD_NOTFOUND\n");
40 Printf("Checking status value for running child id\n");
41 childstatus = ChildStatus(childid);
42 assert(childstatus == CHILD_ACTIVE);
43 Printf("Result: CHILD_ACTIVE\n");
44 ChildWait(childid);
45 Printf("Checking status value for died child id\n");
46 childstatus = ChildStatus(childid);
47 assert(childstatus == CHILD_EXITED);
48 Printf("Result: CHILD_EXITED\n");
49 ChildFree(childid);
50 Printf("Checking status value for freed child id\n");
51 childstatus = ChildStatus(childid);
52 assert(childstatus == CHILD_NOTFOUND);
53 Printf("Result: CHILD_NOTFOUND\n");
55 else
56 PrintFault(IoErr(), "Couldn't create child process");
57 return 0;