pledge-test-failures.cpp 456 B

12345678910111213141516171819202122232425
  1. #include <stdio.h>
  2. #include <unistd.h>
  3. int main()
  4. {
  5. int res = pledge("stdio unix rpath", "stdio");
  6. if (res < 0) {
  7. perror("pledge");
  8. return 1;
  9. }
  10. res = pledge("stdio unix", "stdio unix");
  11. if (res >= 0) {
  12. fprintf(stderr, "second pledge should have failed\n");
  13. return 1;
  14. }
  15. res = pledge("stdio rpath", "stdio");
  16. if (res < 0) {
  17. perror("pledge");
  18. return 1;
  19. }
  20. return 0;
  21. }