N
norm4h8
Hi everyone!
I have a problem with trying to open a file in C.
The following line in my code is suppoed to open a specified file if it
exists and create a new one with this name if one doesn't exist:
if ((shfd = open(argv[2], O_CREAT | O_RDWR, 0644)) < 0)
my_error("open failed");
If I try to open a file that doesn't exist I get an error:
Bus error
And when it creates a file it sets permissions to -rw------ instead of
-rw-r--r-- as I would hope... Is there something I'm not getting about
how O_CREATE works?...
However, if I try to open existing file that is not empty, it works
fine...
Course anyone please help me?
thank you
I have a problem with trying to open a file in C.
The following line in my code is suppoed to open a specified file if it
exists and create a new one with this name if one doesn't exist:
if ((shfd = open(argv[2], O_CREAT | O_RDWR, 0644)) < 0)
my_error("open failed");
If I try to open a file that doesn't exist I get an error:
Bus error
And when it creates a file it sets permissions to -rw------ instead of
-rw-r--r-- as I would hope... Is there something I'm not getting about
how O_CREATE works?...
However, if I try to open existing file that is not empty, it works
fine...
Course anyone please help me?
thank you