1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-18 18:55:07 +00:00
serenity/Userland/Tests/LibC/exec-should-not-search-current-directory.cpp
2020-08-02 17:15:36 +02:00

20 lines
386 B
C++

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
int main()
{
int fd = open("hax", O_CREAT | O_RDWR, 0755);
ftruncate(fd, 0);
close(fd);
int rc = execlp("hax", "hax", nullptr);
int saved_errno = errno;
unlink("hax");
if (rc == -1 && saved_errno == ENOEXEC) {
printf("FAIL\n");
return 1;
}
printf("PASS\n");
return 0;
}