fork.c 228 B

12345678910111213141516171819
  1. #include "lib.h"
  2. #include <errno.h>
  3. #include <unistd.h>
  4. #include "sys9.h"
  5. pid_t
  6. fork(void)
  7. {
  8. int n;
  9. n = _RFORK(RFENVG|RFFDG|RFPROC);
  10. if(n < 0)
  11. _syserrno();
  12. if(n == 0) {
  13. _detachbuf();
  14. _sessleader = 0;
  15. }
  16. return n;
  17. }