2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
5 Desc: Create a new process (in an old way).
9 #include "dos_intern.h"
10 #include <dos/dostags.h>
11 #include <proto/exec.h>
13 /*****************************************************************************
16 #include <proto/dos.h>
18 AROS_LH4(struct MsgPort
*, CreateProc
,
21 AROS_LHA(CONST_STRPTR
, name
, D1
),
22 AROS_LHA(LONG
, pri
, D2
),
23 AROS_LHA(BPTR
, segList
, D3
),
24 AROS_LHA(LONG
, stackSize
, D4
),
27 struct DosLibrary
*, DOSBase
, 23, Dos
)
30 CreateProc() will create a new process (a process is a superset
31 of an exec Task), with the name 'name' and the priority 'pri'.
33 You should pass a segList as returned by LoadSeg() (or similar)
34 in the 'segList' parameter, and specify the stack size in
37 You should really use CreateNewProc() rather than this function
38 as it is much more flexible.
41 name -- Name of the new process.
42 pri -- Starting priority.
43 segList -- BCPL pointer to a seglist.
44 stackSize -- The size of the initial process stack.
47 Pointer to the pr_MsgPort in the Process structure. Will
48 return NULL on failure.
51 This will not free the seglist when the process finishes.
53 This does not return a pointer to the Process structure, but
54 rather the MsgPort structure contained within it. You can
55 get the real Process structure by:
61 pr = (struct Process *)((struct Task *)mp - 1);
63 // Shouldn't use mp after this point
70 CreateNewProc(), LoadSeg(), UnLoadSeg()
73 Basically passes this call to CreateNewProc().
75 *****************************************************************************/
79 struct Process
*pr
; /* The process to create */
80 struct Process
*parent
= (struct Process
*)FindTask(NULL
);
81 APTR windowPtr
= NULL
;
83 /* If the caller is a process, inherit its window pointer */
84 if (__is_process(parent
))
86 windowPtr
= parent
->pr_WindowPtr
;
90 /* Don't forget to find out some extra defaults here */
91 struct TagItem procTags
[] =
93 { NP_Seglist
, (IPTR
)segList
},
94 { NP_FreeSeglist
, FALSE
},
95 { NP_StackSize
, stackSize
},
96 { NP_Name
, (IPTR
)name
},
97 { NP_Priority
, pri
},
98 { NP_WindowPtr
, (IPTR
)windowPtr
},
99 { NP_CurrentDir
, 0 },
103 { NP_CloseInput
, FALSE
},
104 { NP_CloseOutput
, FALSE
},
108 if ((pr
= CreateNewProc(procTags
)))
110 return (struct MsgPort
*)&pr
->pr_MsgPort
;