const char *filename = "some/file"; int fd = open(filename, O_RDONLY); if (fd < 0) { perror(filename); exit(1); }