The executable files that gcc creates have execution permissions
-rwxrwxr-x
which are different than the permissions that the source file has.
-rw-rw-r--
How does gcc set these permissions ?
|
The executable files that
which are different than the permissions that the source file has.
How does |
|||
|
Four things intervene to determine the permission of a file.
Some popular choices of permission sets for step 1 are:
It's the umask that causes files not to be world-readable even though applications can and usually do include the others-write permission in the file creation permissions. In the case of gcc, the output file is first created with permissions 666 (masked by the umask), then later chmod'ed to make it executable. Gcc could create an executable directly, but doesn't: it only makes the file executable when it's finished writing it, so that you don't risk starting to execute the program while it's incomplete. |
|||
|
|
|
I'm not positive what you're asking; you mean how does it have permission to set them? A file's owner can set the permissions to whatever they want. |
|||||||
|
|
As @AshRj's comment above says, this depends on the default permissions the account has set. Essentially what is done is to start with all permissions (that includes, specifically, |
|||
|
|
.os, similarly it wouldn't really make sense to have those be executable. The compiler creates the output, why would it voluntarily not produce the right permissions when it creates the files? – Mat Mar 1 at 14:42