daemon: Gracefully handle Nix errors.
* nix/nix-daemon/guix-daemon.cc (main): Run Nix code in an exception handler; gracefully print error messages, and exit with EXIT_FAILURE.
This commit is contained in:
parent
e2332e8aa7
commit
868fce7c4a
|
@ -27,6 +27,7 @@
|
||||||
#include <argp.h>
|
#include <argp.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
/* Variables used by `nix-daemon.cc'. */
|
/* Variables used by `nix-daemon.cc'. */
|
||||||
volatile ::sig_atomic_t blockInt;
|
volatile ::sig_atomic_t blockInt;
|
||||||
|
@ -170,6 +171,10 @@ main (int argc, char *argv[])
|
||||||
settings.useChroot = false;
|
settings.useChroot = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
argvSaved = argv;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
settings.processEnvironment ();
|
settings.processEnvironment ();
|
||||||
|
|
||||||
/* FIXME: Disable substitutes until we have something that works. */
|
/* FIXME: Disable substitutes until we have something that works. */
|
||||||
|
@ -182,6 +187,13 @@ main (int argc, char *argv[])
|
||||||
fprintf (stderr, "warning: running as root is highly recommended, "
|
fprintf (stderr, "warning: running as root is highly recommended, "
|
||||||
"unless `--build-users-group' is used\n");
|
"unless `--build-users-group' is used\n");
|
||||||
|
|
||||||
argvSaved = argv;
|
|
||||||
run (nothing);
|
run (nothing);
|
||||||
|
}
|
||||||
|
catch (std::exception &e)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "error: %s\n", e.what ());
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return EXIT_SUCCESS; /* never reached */
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue