aboutsummaryrefslogtreecommitdiffstats
path: root/src/blogc-make
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2019-03-28 19:42:13 +0100
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2019-03-28 19:42:13 +0100
commit09139645e866b745c9f8797659f12c90af867015 (patch)
tree846b257841555e5bc91cad1c47eafddc406e19d3 /src/blogc-make
parent35702f4cfcc5ffc21d8dcbf0a9d176118fec2927 (diff)
downloadblogc-09139645e866b745c9f8797659f12c90af867015.tar.gz
blogc-09139645e866b745c9f8797659f12c90af867015.tar.bz2
blogc-09139645e866b745c9f8797659f12c90af867015.zip
make: exit 1 on error
Diffstat (limited to 'src/blogc-make')
-rw-r--r--src/blogc-make/exec-native.c12
-rw-r--r--src/blogc-make/exec.c26
-rw-r--r--src/blogc-make/httpd.c6
-rw-r--r--src/blogc-make/main.c4
-rw-r--r--src/blogc-make/reloader.c4
-rw-r--r--src/blogc-make/rules.c8
6 files changed, 30 insertions, 30 deletions
diff --git a/src/blogc-make/exec-native.c b/src/blogc-make/exec-native.c
index cc734f3..a172193 100644
--- a/src/blogc-make/exec-native.c
+++ b/src/blogc-make/exec-native.c
@@ -55,7 +55,7 @@ bm_exec_native_cp(bm_filectx_t *source, bm_filectx_t *dest, bool verbose)
if (fd_from < 0) {
fprintf(stderr, "blogc-make: error: failed to open source file to copy "
" (%s): %s\n", source->path, strerror(errno));
- return 3;
+ return 1;
}
int fd_to = open(dest->path, O_WRONLY | O_CREAT | O_TRUNC, 0666);
@@ -63,7 +63,7 @@ bm_exec_native_cp(bm_filectx_t *source, bm_filectx_t *dest, bool verbose)
fprintf(stderr, "blogc-make: error: failed to open destination file to "
"copy (%s): %s\n", dest->path, strerror(errno));
close(fd_from);
- return 3;
+ return 1;
}
ssize_t nread;
@@ -77,7 +77,7 @@ bm_exec_native_cp(bm_filectx_t *source, bm_filectx_t *dest, bool verbose)
"destination file (%s): %s\n", dest->path, strerror(errno));
close(fd_from);
close(fd_to);
- return 3;
+ return 1;
}
nread -= nwritten;
out_ptr += nwritten;
@@ -136,7 +136,7 @@ bm_exec_native_rm(const char *output_dir, bm_filectx_t *dest, bool verbose)
if (0 != unlink(dest->path)) {
fprintf(stderr, "blogc-make: error: failed to remove file (%s): %s\n",
dest->path, strerror(errno));
- return 3;
+ return 1;
}
int rv = 0;
@@ -153,7 +153,7 @@ bm_exec_native_rm(const char *output_dir, bm_filectx_t *dest, bool verbose)
if (err != NULL) {
fprintf(stderr, "blogc-make: error: %s\n", err->msg);
bc_error_free(err);
- rv = 3;
+ rv = 1;
break;
}
if (!empty) {
@@ -167,7 +167,7 @@ bm_exec_native_rm(const char *output_dir, bm_filectx_t *dest, bool verbose)
fprintf(stderr,
"blogc-make: error: failed to remove directory(%s): %s\n",
dir, strerror(errno));
- rv = 3;
+ rv = 1;
break;
}
if (0 == strcmp(dir, output_dir)) {
diff --git a/src/blogc-make/exec.c b/src/blogc-make/exec.c
index bc2ecbc..cd71810 100644
--- a/src/blogc-make/exec.c
+++ b/src/blogc-make/exec.c
@@ -77,13 +77,13 @@ bm_exec_command(const char *cmd, const char *input, char **output,
char **error, bc_error_t **err)
{
if (err == NULL || *err != NULL)
- return 3;
+ return 1;
int fd_in[2];
if (-1 == pipe(fd_in)) {
*err = bc_error_new_printf(BLOGC_MAKE_ERROR_EXEC,
"Failed to create stdin pipe: %s", strerror(errno));
- return 3;
+ return 1;
}
int fd_out[2];
@@ -92,7 +92,7 @@ bm_exec_command(const char *cmd, const char *input, char **output,
"Failed to create stdout pipe: %s", strerror(errno));
close(fd_in[0]);
close(fd_in[1]);
- return 3;
+ return 1;
}
int fd_err[2];
@@ -103,7 +103,7 @@ bm_exec_command(const char *cmd, const char *input, char **output,
close(fd_in[1]);
close(fd_out[0]);
close(fd_out[1]);
- return 3;
+ return 1;
}
pid_t pid = fork();
@@ -116,7 +116,7 @@ bm_exec_command(const char *cmd, const char *input, char **output,
close(fd_out[1]);
close(fd_err[0]);
close(fd_err[1]);
- return 3;
+ return 1;
}
// child
@@ -153,7 +153,7 @@ bm_exec_command(const char *cmd, const char *input, char **output,
close(fd_in[1]);
close(fd_out[0]);
close(fd_err[0]);
- return 3;
+ return 1;
}
}
@@ -170,7 +170,7 @@ bm_exec_command(const char *cmd, const char *input, char **output,
close(fd_out[0]);
close(fd_err[0]);
bc_string_free(out, true);
- return 3;
+ return 1;
}
if (out == NULL) {
out = bc_string_new();
@@ -189,7 +189,7 @@ bm_exec_command(const char *cmd, const char *input, char **output,
"Failed to read from stderr pipe: %s", strerror(errno));
close(fd_err[0]);
bc_string_free(out, true);
- return 3;
+ return 1;
}
if (out == NULL)
out = bc_string_new();
@@ -283,7 +283,7 @@ bm_exec_blogc(bm_ctx_t *ctx, bc_trie_t *global_variables, bc_trie_t *local_varia
bool only_first_source)
{
if (ctx == NULL)
- return 3;
+ return 1;
bc_string_t *input = bc_string_new();
for (bc_slist_t *l = sources; l != NULL; l = l->next) {
@@ -315,7 +315,7 @@ bm_exec_blogc(bm_ctx_t *ctx, bc_trie_t *global_variables, bc_trie_t *local_varia
free(err);
bc_string_free(input, true);
bc_error_free(error);
- return 3;
+ return 1;
}
if (rv != 0 && ctx->verbose) {
@@ -355,7 +355,7 @@ bm_exec_blogc(bm_ctx_t *ctx, bc_trie_t *global_variables, bc_trie_t *local_varia
free(out);
free(err);
- return rv == 127 ? 3 : rv;
+ return rv == 127 ? 1 : rv;
}
@@ -364,7 +364,7 @@ bm_exec_blogc_runserver(bm_ctx_t *ctx, const char *host, const char *port,
const char *threads)
{
if (ctx == NULL)
- return 3;
+ return 1;
bc_string_t *cmd = bc_string_new();
@@ -408,7 +408,7 @@ bm_exec_blogc_runserver(bm_ctx_t *ctx, const char *host, const char *port,
fprintf(stderr,
"blogc-make: error: blogc-runserver command not found. Maybe "
"it is not installed?\n");
- rv = 3; // blogc-make exists, so we should not return 127
+ rv = 1; // blogc-make exists, so we should not return 127
}
else {
fprintf(stderr,
diff --git a/src/blogc-make/httpd.c b/src/blogc-make/httpd.c
index 8795a86..adf9a9b 100644
--- a/src/blogc-make/httpd.c
+++ b/src/blogc-make/httpd.c
@@ -65,7 +65,7 @@ bm_httpd_run(bm_ctx_t **ctx, bm_rule_exec_func_t rule_exec, bc_slist_t *outputs,
if (0 != (err = pthread_attr_init(&attr))) {
fprintf(stderr, "blogc-make: error: failed to initialize httpd "
"thread attributes: %s\n", strerror(err));
- return 3;
+ return 1;
}
// we run the thread detached, because we don't want to wait it to join
@@ -73,7 +73,7 @@ bm_httpd_run(bm_ctx_t **ctx, bm_rule_exec_func_t rule_exec, bc_slist_t *outputs,
if (0 != (err = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED))) {
fprintf(stderr, "blogc-make: error: failed to mark httpd thread as "
"detached: %s\n", strerror(err));
- return 3;
+ return 1;
}
bm_httpd_t *rv = bc_malloc(sizeof(bm_httpd_t));
@@ -85,7 +85,7 @@ bm_httpd_run(bm_ctx_t **ctx, bm_rule_exec_func_t rule_exec, bc_slist_t *outputs,
fprintf(stderr, "blogc-make: error: failed to create httpd "
"thread: %s\n", strerror(err));
free(rv);
- return 3;
+ return 1;
}
// run the reloader
diff --git a/src/blogc-make/main.c b/src/blogc-make/main.c
index 87b41a4..d9f60b9 100644
--- a/src/blogc-make/main.c
+++ b/src/blogc-make/main.c
@@ -98,7 +98,7 @@ main(int argc, char **argv)
print_usage();
fprintf(stderr, "blogc-make: error: invalid argument: "
"-%c\n", argv[i][1]);
- rv = 3;
+ rv = 1;
goto cleanup;
}
}
@@ -115,7 +115,7 @@ main(int argc, char **argv)
argc > 0 ? argv[0] : NULL, &err);
if (err != NULL) {
bc_error_print(err, "blogc-make");
- rv = 3;
+ rv = 1;
goto cleanup;
}
ctx->dev = dev;
diff --git a/src/blogc-make/reloader.c b/src/blogc-make/reloader.c
index d08d49c..fea8bd4 100644
--- a/src/blogc-make/reloader.c
+++ b/src/blogc-make/reloader.c
@@ -42,7 +42,7 @@ bm_reloader_run(bm_ctx_t **ctx, bm_rule_exec_func_t rule_exec,
struct sigaction current_action;
if (sigaction(SIGINT, NULL, &current_action) < 0) {
fprintf(stderr, "blogc-make: failed to run reloader: %s\n", strerror(errno));
- return 3;
+ return 1;
}
if (current_action.sa_handler != sig_handler) { // not installed yet
// backup current handler
@@ -58,7 +58,7 @@ bm_reloader_run(bm_ctx_t **ctx, bm_rule_exec_func_t rule_exec,
if (sigaction(SIGINT, &new_action, NULL) < 0) {
fprintf(stderr, "blogc-make: failed to run reloader: %s\n",
strerror(errno));
- return 3;
+ return 1;
}
}
diff --git a/src/blogc-make/rules.c b/src/blogc-make/rules.c
index b29aab2..5361502 100644
--- a/src/blogc-make/rules.c
+++ b/src/blogc-make/rules.c
@@ -634,7 +634,7 @@ atom_dump_exec(bm_ctx_t *ctx, bc_slist_t *outputs, bc_trie_t *args)
{
char *content = bm_atom_generate(ctx->settings);
if (content == NULL)
- return 3;
+ return 1;
printf("%s", content);
free(content);
return 0;
@@ -794,7 +794,7 @@ int
bm_rule_executor(bm_ctx_t *ctx, bc_slist_t *rule_list)
{
if (ctx == NULL)
- return 3;
+ return 1;
const bm_rule_t *rule = NULL;
int rv = 0;
@@ -831,7 +831,7 @@ bm_rule_executor(bm_ctx_t *ctx, bc_slist_t *rule_list)
if (rule == NULL) {
fprintf(stderr, "blogc-make: error: rule not found: %.*s\n",
(int) (sep - rule_str), rule_str);
- rv = 3;
+ rv = 1;
}
}
@@ -843,7 +843,7 @@ int
bm_rule_execute(bm_ctx_t *ctx, const bm_rule_t *rule, bc_trie_t *args)
{
if (ctx == NULL || rule == NULL)
- return 3;
+ return 1;
bc_slist_t *outputs = NULL;
if (rule->outputlist_func != NULL) {