summaryrefslogtreecommitdiff
path: root/usr.sbin/init
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/init')
-rw-r--r--usr.sbin/init/Makefile2
-rw-r--r--usr.sbin/init/main.c23
2 files changed, 23 insertions, 2 deletions
diff --git a/usr.sbin/init/Makefile b/usr.sbin/init/Makefile
index bee9f3a..5f95379 100644
--- a/usr.sbin/init/Makefile
+++ b/usr.sbin/init/Makefile
@@ -2,5 +2,5 @@ include user.mk
CFILES = $(shell find . -name "*.c")
-init:
+$(ROOT)/base/usr/sbin/init:
gcc $(CFILES) -o $@ $(INTERNAL_CFLAGS)
diff --git a/usr.sbin/init/main.c b/usr.sbin/init/main.c
index a136740..bad8201 100644
--- a/usr.sbin/init/main.c
+++ b/usr.sbin/init/main.c
@@ -27,8 +27,29 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <sys/spawn.h>
+#include <stddef.h>
+
+#define SHELL_PATH "/usr/bin/osh"
+#define INIT_RC_PATH "/usr/rc/init.rc"
+
int
-main(void)
+main(int argc, char **argv)
{
+ char *start_argv[] = { SHELL_PATH, INIT_RC_PATH, NULL };
+ char *start_envp[] = { NULL };
+
+ spawn(SHELL_PATH, start_argv, start_envp, 0);
+ start_argv[1] = NULL;
+
+ /*
+ * We can override the start program header
+ * if there is something specified.
+ */
+ if (argc > 1) {
+ start_argv[0] = argv[1];
+ }
+
+ spawn(start_argv[0], start_argv, start_envp, SPAWN_WAIT);
return 0;
}