aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2024-02-06 09:31:21 -0500
committerJoseph Hunkeler <jhunkeler@gmail.com>2024-02-06 09:31:21 -0500
commit5e58d1a75edb3b057fe7291f3835c9ded076b0c8 (patch)
tree8863f36dac47a3747f06965b1403c34bcdfd5803
parent03d49ec76e6c4460627b8ebcbd065b0dfac551ae (diff)
downloadstasis-5e58d1a75edb3b057fe7291f3835c9ded076b0c8.tar.gz
Refactor std{out,err} to f_std{out,err}
* Bare stdout and stderr, even as struct members, tend to conflict with numerous libc implementations.
-rw-r--r--include/system.h8
-rw-r--r--src/artifactory.c4
-rw-r--r--src/conda.c4
-rw-r--r--src/main.c4
-rw-r--r--src/system.c8
5 files changed, 16 insertions, 12 deletions
diff --git a/include/system.h b/include/system.h
index 8ad613f..cdbefd8 100644
--- a/include/system.h
+++ b/include/system.h
@@ -15,9 +15,13 @@
#include <sys/stat.h>
struct Process {
- char stdout[PATH_MAX];
- char stderr[PATH_MAX];
+ // Write stdout stream to file
+ char f_stdout[PATH_MAX];
+ // Write stderr stream to file
+ char f_stderr[PATH_MAX];
+ // Combine stderr and stdout (into stdout stream)
int redirect_stderr;
+ // Exit code from program
int returncode;
};
diff --git a/src/artifactory.c b/src/artifactory.c
index 972f27b..790d9ed 100644
--- a/src/artifactory.c
+++ b/src/artifactory.c
@@ -198,8 +198,8 @@ int jfrog_cli(struct JFRT_Auth *auth, char *args) {
msg(OMC_MSG_L2, "Executing: %s\n", cmd_redacted);
if (!globals.verbose) {
- strcpy(proc.stdout, "/dev/null");
- strcpy(proc.stderr, "/dev/null");
+ strcpy(proc.f_stdout, "/dev/null");
+ strcpy(proc.f_stderr, "/dev/null");
}
status = shell(&proc, cmd);
return status;
diff --git a/src/conda.c b/src/conda.c
index 40b40f9..acec709 100644
--- a/src/conda.c
+++ b/src/conda.c
@@ -82,7 +82,7 @@ int conda_activate(const char *root, const char *env_name) {
close(fd);
// Configure our process for output to a log file
- strcpy(proc.stdout, logfile);
+ strcpy(proc.f_stdout, logfile);
// Verify conda's init scripts are available
if (access(path_conda, F_OK) < 0) {
@@ -111,7 +111,7 @@ int conda_activate(const char *root, const char *env_name) {
// 1. Extract the environment keys and values from the sub-shell
// 2. Apply it to OMC's runtime environment
// 3. Now we're ready to execute conda commands anywhere
- fp = fopen(proc.stdout, "r");
+ fp = fopen(proc.f_stdout, "r");
if (!fp) {
perror(logfile);
return -1;
diff --git a/src/main.c b/src/main.c
index d1df20e..fbc3888 100644
--- a/src/main.c
+++ b/src/main.c
@@ -118,8 +118,8 @@ int main(int argc, char *argv[], char *arge[]) {
struct INIFILE *ini = NULL;
struct Delivery ctx;
struct Process proc = {
- .stdout = "",
- .stderr = "",
+ .f_stdout = "",
+ .f_stderr = "",
.redirect_stderr = 0,
};
char env_name[OMC_NAME_MAX] = {0};
diff --git a/src/system.c b/src/system.c
index 2a5302e..a8b966f 100644
--- a/src/system.c
+++ b/src/system.c
@@ -32,12 +32,12 @@ int shell(struct Process *proc, char *args) {
} else if (pid == 0) {
int retval;
if (proc != NULL) {
- if (strlen(proc->stdout)) {
- fp_out = freopen(proc->stdout, "w+", stdout);
+ if (strlen(proc->f_stdout)) {
+ fp_out = freopen(proc->f_stdout, "w+", stdout);
}
- if (strlen(proc->stderr)) {
- fp_err = freopen(proc->stderr, "w+", stderr);
+ if (strlen(proc->f_stderr)) {
+ fp_err = freopen(proc->f_stderr, "w+", stderr);
}
if (proc->redirect_stderr) {