init_env_poweroff.c 428 B

1234567891011121314151617181920212223242526
  1. #define _XOPEN_SOURCE 700
  2. #include <stdio.h>
  3. #include <sys/reboot.h>
  4. #include <unistd.h>
  5. int main(int argc, char **argv) {
  6. int i;
  7. puts("args:");
  8. for (i = 0; i < argc; ++i)
  9. puts(argv[i]);
  10. puts("");
  11. puts("env:");
  12. extern char **environ;
  13. char **env = environ;
  14. while (*env) {
  15. printf("%s\n", *env);
  16. env++;
  17. }
  18. puts("");
  19. /* Poweroff. */
  20. reboot(RB_POWER_OFF);
  21. }