errno.c 525 B

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