2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
5 Desc: Execute a loaded command synchonously
8 #include <exec/memory.h>
9 #include <proto/exec.h>
10 #include <utility/tagitem.h>
11 #include <dos/filesystem.h>
12 #include <proto/dos.h>
13 #include "dos_intern.h"
15 LONG
AROS_SLIB_ENTRY(RunProcess
,Dos
)
17 struct Process
* proc
,
18 struct StackSwapStruct
* sss
,
22 struct DosLibrary
* DOSBase
25 /*****************************************************************************
28 #include <proto/dos.h>
30 AROS_LH4(LONG
, RunCommand
,
33 AROS_LHA(BPTR
, segList
, D1
),
34 AROS_LHA(ULONG
, stacksize
, D2
),
35 AROS_LHA(STRPTR
, argptr
, D3
),
36 AROS_LHA(ULONG
, argsize
, D4
),
39 struct DosLibrary
*, DOSBase
, 84, Dos
)
42 RunCommand() will run the command loaded in the |segList| with the
43 arguments specified with a new stack of |stacksize| bytes. Note
44 that the stacksize may be extended if this is required.
46 The return code of the command run will be returned.
48 AROS ONLY: RunCommand() automatically computes argsize
49 automatically if you pass -1.
51 This call will not return until the command has completed.
54 segList - segment of program to run.
55 stacksize - size of the stack to use.
56 argptr - pointer to NULL-terminated arguments.
57 argsize - size of the arguments string.
60 The return code from the program. See also IoErr().
63 Programs expect the arugment string to end with a newline ('\n')
64 character (ReadArgs() requires it to work properly).
75 *****************************************************************************/
82 /* Get pointer to process structure */
83 struct Process
*me
=(struct Process
*)FindTask(NULL
);
87 struct StackSwapStruct sss
;
89 if(stacksize
< AROS_STACKSIZE
)
90 stacksize
= AROS_STACKSIZE
;
92 stack
=(UBYTE
*)AllocMem(stacksize
,MEMF_ANY
);
97 sss
.stk_Upper
=stack
+stacksize
;
99 oldresult
=me
->pr_Result2
;
101 me
->pr_Result2
=oldresult
;
103 oldargs
=me
->pr_Arguments
;
104 me
->pr_Arguments
=argptr
;
106 ret
=AROS_SLIB_ENTRY(RunProcess
,Dos
)(me
,&sss
,argptr
,argsize
,
107 (LONG_FUNC
)((BPTR
*)BADDR(segList
)+1),DOSBase
);
108 me
->pr_Arguments
=oldargs
;
110 oldresult
=me
->pr_Result2
;
112 me
->pr_Result2
=oldresult
;
114 FreeMem(stack
,stacksize
);