errno.c 497 B

123456789101112131415161718192021222324252627
  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. int child_fn(void *arg)
  7. {
  8. fprintf(stderr, "in child_fn\n");
  9. exit(1);
  10. }
  11. int main(void)
  12. {
  13. int r_clone, ret_errno;
  14. r_clone = clone(child_fn, NULL, (int) NULL, NULL);
  15. ret_errno = errno;
  16. if (ret_errno != EINVAL || r_clone != -1) {
  17. fprintf(stderr, "clone: res=%d (wanted -1) errno=%d (wanted %d)\n",
  18. r_clone, errno, EINVAL);
  19. return 1;
  20. }
  21. return 0;
  22. }