diff options
author | Joseph Hunkeler <jhunkeler@users.noreply.github.com> | 2024-10-04 08:40:39 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-04 08:40:39 -0400 |
commit | d7e3deba72703ad36c497f5becf6772ca00a0d6d (patch) | |
tree | eff3b2ec3dcc31126041529c8e00a714997f2d7b /src/system.c | |
parent | 9691ccf51b3efd8113e9620c4afa8b5382d7f161 (diff) | |
parent | f0ba8cd378a460f927644e41f49be95d0e956f81 (diff) | |
download | stasis-d7e3deba72703ad36c497f5becf6772ca00a0d6d.tar.gz |
Merge pull request #46 from jhunkeler/split-delivery-code
Add multiprocessing / Split delivery code
Diffstat (limited to 'src/system.c')
-rw-r--r-- | src/system.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/system.c b/src/system.c index a564769..4e605ec 100644 --- a/src/system.c +++ b/src/system.c @@ -46,11 +46,19 @@ int shell(struct Process *proc, char *args) { if (strlen(proc->f_stdout)) { fp_out = freopen(proc->f_stdout, "w+", stdout); + if (!fp_out) { + fprintf(stderr, "Unable to redirect stdout to %s: %s\n", proc->f_stdout, strerror(errno)); + exit(1); + } } if (strlen(proc->f_stderr)) { if (!proc->redirect_stderr) { fp_err = freopen(proc->f_stderr, "w+", stderr); + if (!fp_err) { + fprintf(stderr, "Unable to redirect stderr to %s: %s\n", proc->f_stdout, strerror(errno)); + exit(1); + } } } @@ -59,7 +67,10 @@ int shell(struct Process *proc, char *args) { fclose(fp_err); fclose(stderr); } - dup2(fileno(stdout), fileno(stderr)); + if (dup2(fileno(stdout), fileno(stderr)) < 0) { + fprintf(stderr, "Unable to redirect stderr to stdout: %s\n", strerror(errno)); + exit(1); + } } return execl("/bin/bash", "bash", "--norc", t_name, (char *) NULL); |