errno.c 554 B

1234567891011121314151617181920212223242526272829
  1. /* based originally on one the clone tests in the LTP */
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <errno.h>
  5. #include <sched.h>
  6. #include "clone_cruft.h"
  7. __attribute__ ((__noreturn__))
  8. static int child_fn(void *arg)
  9. {
  10. fprintf(stderr, "in child_fn\n");
  11. exit(1);
  12. }
  13. int main(void)
  14. {
  15. int r_clone, ret_errno;
  16. r_clone = do_clone(child_fn, NULL, 0, NULL);
  17. ret_errno = errno;
  18. if (ret_errno != EINVAL || r_clone != -1) {
  19. fprintf(stderr, "clone: res=%d (wanted -1) errno=%d (wanted %d)\n",
  20. r_clone, errno, EINVAL);
  21. return 1;
  22. }
  23. return 0;
  24. }