I was reading wikipedia on Segmentation Faults and come through following code and statements.
int main(void)
{
char *s = "hello world";
*s = 'H';
}
When the program containing this code is compiled, the string "hello world" is placed in the section of the program executable file marked as read-only; when loaded, the operating system places it with other strings and constant data in a read-only segment of memory. When executed, a variable, s, is set to point to the string's location, and an attempt is made to write an H character through the variable into the memory, causing a segmentation fault. Compiling such a program with a compiler that does not check for the assignment of read-only locations at compile time.
My question is on file permission i.e, when executables marked as read-only and when read and write and so on ?
I want to know all about file permissions.Can we change the file permission explicitly?
mprotect()
on POSIX systems. – FatalError