How can my C program check if it has execution permission on a given file?
问题 Is there a way to determine if the process may execute a file without having to actually execute it (e.g. by calling execv(filepath, args) only to fail and discover that errno == EACCES )? I could stat the file and observe st_mode , but then I still don’t know how that pertains to the process. Ideally, I’m looking for a function along the lines of get_me_permissions(filepath, &status); // me: the process calling this function // when decoded, status tells if the process can read, write, and