aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bbot/worker/worker.cli4
-rw-r--r--bbot/worker/worker.cxx40
2 files changed, 31 insertions, 13 deletions
diff --git a/bbot/worker/worker.cli b/bbot/worker/worker.cli
index eda79d7..04b2e70 100644
--- a/bbot/worker/worker.cli
+++ b/bbot/worker/worker.cli
@@ -97,6 +97,8 @@ namespace bbot
"
\h|EXIT STATUS|
- Non-zero exit status is returned in case of an error.
+ Non-zero exit status is returned in case of an error. In the build mode,
+ exit code 2 is used to signal abnormal termination where the worker
+ uploaded the result manifest itself.
"
}
diff --git a/bbot/worker/worker.cxx b/bbot/worker/worker.cxx
index a41dcde..a6b2a37 100644
--- a/bbot/worker/worker.cxx
+++ b/bbot/worker/worker.cxx
@@ -41,7 +41,7 @@ namespace bbot
int
main (int argc, char* argv[]);
- static void
+ static int
build (size_t argc, const char* argv[]);
process_path argv0;
@@ -254,7 +254,7 @@ run_b (tracer& t,
return run_b (t, log, warn_detect, envvars, buildspec, forward<A> (a)...);
}
-static void bbot::
+static int bbot::
build (size_t argc, const char* argv[])
{
tracer trace ("build");
@@ -899,9 +899,14 @@ build (size_t argc, const char* argv[])
{
fail << "unable to upload result manifest to " << url << ": " << e;
}
+
+ // We use exit code 2 to signal abnormal termination but where we managed
+ // to upload the result manifest. See startup() for details.
+ //
+ return rm.status != result_status::abnormal ? 0 : 2;
}
-static void
+static int
startup ()
{
tracer trace ("startup");
@@ -1015,7 +1020,15 @@ startup ()
// Note that we use the effective (absolute) path instead of recall since
// we may have changed the CWD.
//
- run (trace, pp, tg, argv0.effect_string (), os);
+ // Exit code 2 signals abnormal termination but where the worker uploaded
+ // the result itself.
+ //
+ switch (run_exit (trace, pp, tg, argv0.effect_string (), os))
+ {
+ case 2: return 1;
+ case 0: return 0;
+ default: fail << "process " << pp << " exited with non-zero code" << endf;
+ }
}
catch (const failed&)
{
@@ -1046,14 +1059,14 @@ startup ()
}
catch (const system_error& e)
{
- error << "unable to upload result manifest to " << url << ": " << e;
+ fail << "unable to upload result manifest to " << url << ": " << e;
}
- throw;
+ return 1;
}
}
-static void
+static int
bootstrap ()
{
bootstrap_manifest bm {
@@ -1066,6 +1079,8 @@ bootstrap ()
};
serialize_manifest (bm, cout, "stdout", "bootstrap");
+
+ return 0;
}
int bbot::
@@ -1192,15 +1207,16 @@ try
fail << "invalid environment directory: " << e;
}
+ int r (1);
switch (m)
{
- case mode::boot: bootstrap (); break;
- case mode::start: startup (); break;
- case mode::build: build (static_cast<size_t> (argc),
- const_cast<const char**> (argv)); break;
+ case mode::boot: r = bootstrap (); break;
+ case mode::start: r = startup (); break;
+ case mode::build: r = build (static_cast<size_t> (argc),
+ const_cast<const char**> (argv)); break;
}
- return 0;
+ return r;
}
catch (const failed&)
{