I would like to open a file in C where the reads and writes are both synchronized. Is the proper way
fopen("file.txt", O_DSYNCH | O_RSYNCH)
or
fopen("file.txt", O_SYNCH)
This is for use on Linux
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
From
man 3 open:Therefore, the correct call is
Note that
fopendoes not takeO_flags (it uses mode strings like"r+"), and you therefore cannot use any of theO_*SYNCoptions with it directly.