Skip to content
Advertisement

system call open() creating executable

JavaScript

So my code creates and writes to the out_file properly. However, the file is an executable for some reason. I think the fault is in my open() call but I can’t seem to find why.

Advertisement

Answer

man 2 open explains why:

JavaScript

So if you want a file that’s not executable, you can use:

JavaScript

0666 will suggest read/write for all (equivalent to the constant flags S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH), and the user’s umask will further limit the final permissions to the user’s chosen default.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement