2 Copyright © 1995-2008, The AROS Development Team. All rights reserved.
5 Desc: Execute a loaded command synchronously
8 #include <exec/memory.h>
9 #include "../exec/etask.h"
10 #include <proto/exec.h>
11 #include <utility/tagitem.h>
12 #include <dos/filesystem.h>
13 #include <proto/dos.h>
14 #include "dos_intern.h"
16 LONG
AROS_SLIB_ENTRY(RunProcess
,Dos
)
18 struct Process
* proc
,
19 struct StackSwapStruct
* sss
,
23 struct DosLibrary
* DOSBase
26 /*****************************************************************************
29 #include <proto/dos.h>
31 AROS_LH4(LONG
, RunCommand
,
34 AROS_LHA(BPTR
, segList
, D1
),
35 AROS_LHA(ULONG
, stacksize
, D2
),
36 AROS_LHA(CONST_STRPTR
, argptr
, D3
),
37 AROS_LHA(ULONG
, argsize
, D4
),
40 struct DosLibrary
*, DOSBase
, 84, Dos
)
43 RunCommand() will run the command loaded in the |segList| with the
44 arguments specified with a new stack of |stacksize| bytes. Note
45 that the stacksize may be extended if this is required.
47 The return code of the command run will be returned.
49 AROS ONLY: RunCommand() automatically computes argsize
50 automatically if you pass -1.
52 This call will not return until the command has completed.
55 segList - segment of program to run.
56 stacksize - size of the stack to use.
57 argptr - pointer to NULL-terminated arguments.
58 argsize - size of the arguments string.
61 The return code from the program. See also IoErr().
64 Programs expect the argument string to end with a newline ('\n')
65 character (ReadArgs() requires it to work properly).
76 *****************************************************************************/
82 struct aros_startup
* oldstartup
;
84 /* Get pointer to process structure */
85 struct Process
*me
=(struct Process
*)FindTask(NULL
);
89 struct StackSwapStruct sss
;
91 if(stacksize
< AROS_STACKSIZE
)
92 stacksize
= AROS_STACKSIZE
;
94 stack
=(UBYTE
*)AllocMem(stacksize
,MEMF_ANY
);
99 sss
.stk_Upper
=stack
+stacksize
;
101 oldresult
=me
->pr_Result2
;
102 /* we have to save iet_startup field because it's overwritten in
104 oldstartup
= (struct aros_startup
*)GetIntETask(me
)->iet_startup
;
106 me
->pr_Result2
=oldresult
;
108 oldargs
=me
->pr_Arguments
;
109 me
->pr_Arguments
=(STRPTR
)argptr
;
111 ret
=AROS_SLIB_ENTRY(RunProcess
,Dos
)(me
,&sss
,argptr
,argsize
,
112 (LONG_FUNC
)((BPTR
*)BADDR(segList
)+1),DOSBase
);
113 me
->pr_Arguments
=oldargs
;
115 oldresult
=me
->pr_Result2
;
116 /* restore saved iet_startup */
117 GetIntETask(me
)->iet_startup
= oldstartup
;
119 me
->pr_Result2
=oldresult
;
121 FreeMem(stack
,stacksize
);