-
Notifications
You must be signed in to change notification settings - Fork 21
use different exit codes in argv parsing #179
Conversation
what I forgot to include in the comment above is the output with these changes in: with
with
anyone (@mirage/core) has an opinion on this? I'd like to merge and release this monday (oct 14th) evening. |
I'm in favour of this. Although it's a bigger change, it may be worth us standardising on |
NB: yes, I'm aware of the ~> maybe we should have a small package "exit-codes" that define a mapping between constructor and numeric value? this could then serve as a global registry, to-be-used in the various libraries that should deal with errors? |
I found http://www.tldp.org/LDP/abs/html/exitcodes.html which covers some more exit codes (all non-overlapping with either sysexits nor the ones proposed here), mainly for shell programming. |
If we're going to interpret exit codes, I should go through the Solo5 code and at least distinguish between:
Both of these cases currently return (related: Solo5/solo5#424) |
@mato thanks for your explanation. it would be nice to document (and maybe adjust/unify) exit codes, but this is really not urgent. |
…line processor): - on parse failure, 64 - if help or version was requested, 63 reasoning is to design reasonable restart-on-failure semantics.
require dune <= 1.5.1 for testing
the list from sysexits and bash tutorial is atm as a comment at https://github.com/hannesm/albatross/blob/solo5-6/src/vmm_core.ml#L333-L358, @mato yes, something high would be good! CI is green (after using dune.1.5.3 as test-dependency), merging and releasing |
CHANGES: * Functoria_runtime.with_argv now uses (mirage/functoria#179, by @hannesm) - exit 63 when `Help or `Version is requested (used to exit with 0) - exit 64 when Term.eval returns with an error (used to raise an exception)
Functoria_runtime.with_argv
is parsing the argument vector. This is used by all MirageOS unikernels. It has a three-valued return: success (returns unit),`Help | `Version
- used to be 0), Error (exception, OCaml runtime returns 2).As it looks now when we start
hello
with an argument it cannot handle (--fpoo=bar
):Now, I intended to implement a restart-on-failure feature in albatross. The only information we have at exit is the exit code, and this can be divided into "those which should trigger a restart" (i.e. out of memory in most unikernels, unhandled exception, ..) and "those which should not trigger a restart" (i.e. solo5 tender can't process spt/hvt image, manifest mismatch, boot argument parser error).
FWIW, I figured the following exit codes are used:
void exit(int status)
.abort()
in 4.10.0, see Use abort instead of exit(2) in caml_fatal_error. ocaml/ocaml#8630solo5_abort
Now, while restart-on-failure can be configured by a user with a whitelist of exit code which should trigger a restart, there is need for a sensible default, which is everything besides
1
and the (arbitrary) range64..70
.(this is a PR against 2.2 which I tested locally, if this is accepted I'll of course PR as well against master)