vfork.c 406 B

1234567891011121314151617181920
  1. #include <errno.h>
  2. #include <shim_table.h>
  3. int main(int argc, char** argv) {
  4. pid_t pid = shim_vfork();
  5. if (pid < 0) {
  6. shim_write(1, "failed on fork\n", 15);
  7. shim_exit_group(-1);
  8. }
  9. if (pid == 0) {
  10. shim_write(1, "Hello, Dad!\n", 12);
  11. } else {
  12. shim_write(1, "Hello, Kid!\n", 12);
  13. }
  14. shim_exit_group(0);
  15. return 1; // should not reach here.
  16. }