diff options
author | dzwdz | 2022-07-30 14:52:22 +0200 |
---|---|---|
committer | dzwdz | 2022-07-30 14:52:22 +0200 |
commit | b26399ad055aae9ef4b01694967515235568cd85 (patch) | |
tree | f8eec54655b5461e00596d7aa1f2a27aa5fede25 /src/user/app/init/init.c | |
parent | 9efd7f96b028a69b1da0cf53f6d7be71048c73d7 (diff) |
user: stderr
Diffstat (limited to 'src/user/app/init/init.c')
-rw-r--r-- | src/user/app/init/init.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/user/app/init/init.c b/src/user/app/init/init.c index d7dc34d..bb92cce 100644 --- a/src/user/app/init/init.c +++ b/src/user/app/init/init.c @@ -6,20 +6,21 @@ #include <unistd.h> #include <user/lib/fs/misc.h> +#define die(fmt, ...) do { fprintf(stderr, "init: " fmt, __VA_ARGS__); exit(1); } while (0) + void redirect(const char *exe, const char *out, const char *in) { if (!fork()) { - if (!freopen(out, "a+", stdout)) { - printf("init: couldn't open %s\n", out); // TODO borked - exit(1); - } - if (!freopen(in, "r", stdin)) { - printf("init: couldn't open %s\n", in); + if (!freopen(out, "a+", stderr)) { + fprintf(stdout, "couldn't open %s\n", out); exit(1); } + if (!freopen(out, "a+", stdout)) + die("couldn't open %s\n", out); + if (!freopen(in, "r", stdin)) + die(" couldn't open %s\n", in); termcook(); execv(exe, NULL); - printf("couldn't start %s\n", exe); - exit(1); + die("couldn't start %s\n", exe); } } |