2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
9 /******************************************************************************
25 Run a program, that is start a program as a background process.
26 That means it doesn't take over the parent shell.
30 COMMAND -- the program to run together with its arguments
36 To make it possible to close the current shell, redirect the output
39 Run >NIL: program arguments
51 ******************************************************************************/
53 #include <exec/memory.h>
54 #include <proto/exec.h>
55 #include <dos/filesystem.h>
56 #include <dos/dosextens.h>
57 #include <dos/dostags.h>
58 #include <proto/dos.h>
59 #include <utility/tagitem.h>
61 #include <aros/shcommands.h>
64 AROS_SHA(STRPTR
, ,COMMAND
,/F
,NULL
))
68 struct CommandLineInterface
*cli
= Cli();
69 BPTR cis
= NULL
, cos
= NULL
, ces
= NULL
;
77 if (IsInteractive(Input()))
80 toclone
= cli
->cli_StandardInput
;
82 olddir
= CurrentDir(toclone
);
83 cis
= Open("", FMF_READ
);
86 if (IsInteractive(Output()))
89 toclone
= cli
->cli_StandardOutput
;
91 olddir
= CurrentDir(toclone
);
92 cos
= Open("", FMF_WRITE
);
95 /* This is sort of a hack, needed because the original AmigaOS shell didn't allow
96 Error() redirection, so all the scripts written so far assume that only Input() and
97 Output() require to be redirected in order to not block the parent console */
98 if (Error() != cli
->cli_StandardError
&& IsInteractive(Error()))
102 olddir
= CurrentDir(toclone
);
103 ces
= Open("", FMF_WRITE
);
109 struct TagItem tags
[] =
111 { SYS_Input
, (IPTR
)cis
},
112 { SYS_Output
, (IPTR
)cos
},
113 { SYS_Error
, (IPTR
)ces
},
114 { SYS_Background
, TRUE
},
115 { SYS_Asynch
, TRUE
},
116 { SYS_CliNumPtr
, (IPTR
)&CliNum
},
117 { SYS_UserShell
, TRUE
},
122 if (SystemTagList(SHArg(COMMAND
), tags
) == -1)
124 PrintFault(IoErr(), "Run");
134 IPTR data
[1] = { (IPTR
)CliNum
};
135 VPrintf("[CLI %ld]\n", data
);