2 Copyright © 1995-2001, 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 *****************************************************************************/
78 AROS_LIBBASE_EXT_DECL(struct DosLibrary
*,DOSBase
)
83 /* Get pointer to process structure */
84 struct Process
*me
=(struct Process
*)FindTask(NULL
);
88 struct StackSwapStruct sss
;
90 if(stacksize
< AROS_STACKSIZE
)
91 stacksize
= AROS_STACKSIZE
;
93 stack
=(UBYTE
*)AllocMem(stacksize
,MEMF_ANY
);
98 sss
.stk_Upper
=stack
+stacksize
;
100 oldresult
=me
->pr_Result2
;
102 me
->pr_Result2
=oldresult
;
104 oldargs
=me
->pr_Arguments
;
105 me
->pr_Arguments
=argptr
;
107 ret
=AROS_SLIB_ENTRY(RunProcess
,Dos
)(me
,&sss
,argptr
,argsize
,
108 (LONG_FUNC
)((BPTR
*)BADDR(segList
)+1),DOSBase
);
109 me
->pr_Arguments
=oldargs
;
111 oldresult
=me
->pr_Result2
;
113 me
->pr_Result2
=oldresult
;
115 FreeMem(stack
,stacksize
);