env.c 563 B

123456789101112131415161718192021
  1. #include <stdlib.h>
  2. #include <reproc/run.h>
  3. // Runs a binary as a child process that prints all its environment variables to
  4. // stdout and exits. Additional environment variables (in the format A=B) passed
  5. // via the command line are added to the child process environment variables.
  6. int main(int argc, const char **argv)
  7. {
  8. (void) argc;
  9. const char *args[] = { RESOURCE_DIRECTORY "/env", NULL };
  10. int r = reproc_run(args, (reproc_options){ .env.extra = argv + 1 });
  11. if (r < 0) {
  12. fprintf(stderr, "%s\n", reproc_strerror(r));
  13. }
  14. return abs(r);
  15. }