summaryrefslogtreecommitdiff
path: root/src/user/app/init/main.cpp
blob: 759d804c0b22578125b58e460bae5377cdaa0d0d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <tce/syscall.h>
#include <IO/IOStream.h>
#include <String.h>

int Main(String *args) {
	FILE home_term = libc::open("/.ui/home", 0);
	if (home_term < 0) return -1;

	stdio << "(init) Trivial/Computing Environment says hello. Press super to go home.\n";

	for (int i = 0; args[i]; i++) {
		if (i == 0) continue;
		stdio.printf("(init) Spawning %s...\n", args[i].c_str());
		int pid = libc::run(args[i].c_str(), 0, home_term);
		if (pid < 0) {
			stdio << "(init) Error. Sorry.\n";
		} else {
			libc::waitpid(pid, 1);
		}
	}
	stdio << "(init) Goodbye.\n";
	return 0;
}