CE implement running commands from script files
This commit is contained in:
29
init/init.c
29
init/init.c
@@ -12,7 +12,7 @@
|
||||
|
||||
static int ce_pgid;
|
||||
|
||||
void receiver (void* arg) {
|
||||
static void receiver (void* arg) {
|
||||
(void)arg;
|
||||
|
||||
char recv[RECV_MAX];
|
||||
@@ -27,9 +27,7 @@ void receiver (void* arg) {
|
||||
}
|
||||
}
|
||||
|
||||
void app_main (void) {
|
||||
debug_printf ("Init process is running. Starting user shell...\n");
|
||||
|
||||
static void run_ce_interactive (void) {
|
||||
int ce_pid = exec ("sys", "/ce");
|
||||
ce_pgid = get_procgroup (ce_pid);
|
||||
|
||||
@@ -44,3 +42,26 @@ void app_main (void) {
|
||||
stream_write (ce_pgid, STREAM_IN, &ch, 1);
|
||||
}
|
||||
}
|
||||
|
||||
static void ce_run_init_script (void) {
|
||||
int ce_pid = exec_partial ("sys", "/ce");
|
||||
ce_pgid = get_procgroup (ce_pid);
|
||||
|
||||
const char* script_path = "sys:/init.cmd";
|
||||
env_set (ce_pgid, "s", (void*)script_path, strlen (script_path) + 1);
|
||||
|
||||
struct process_data* recv_pdata = process_spawn (&receiver, NULL);
|
||||
|
||||
exec_partial_fini (ce_pgid);
|
||||
|
||||
wait_for_pid (ce_pid);
|
||||
kill (recv_pdata->pid);
|
||||
process_data_free (recv_pdata);
|
||||
}
|
||||
|
||||
void app_main (void) {
|
||||
debug_printf ("Init process is running. Starting user shell...\n");
|
||||
|
||||
ce_run_init_script ();
|
||||
run_ce_interactive ();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user