Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

Shareable writing into file

SOLVED
Go to solution
AlexanderM
Advisor

Shareable writing into file

Hello.

I need to write in a log file from several processes.

I am using the next solution:

int logFile;
logFile = open(stampedPath.ptr, O_WRONLY | O_APPEND | O_CREAT, 0666);
write(logFile, buffer.ptr, buffer.len);//to achieve atomic output
close(logFile);

 In Linux(Red Hat) it works perfectly.

On OpenVMS I've got the next message in the second process: file currently locked by another user.

 

I've read about fwrite with additional keys from c language extension, but it is queit hard to find out in google full manual for this keys.

Furthermore:

  • I am not shure that in this case family of printf functions  will give atomic output (in Linux they allow for a processes to mix output).
  • I dont want to duplicate the code.

Could I resolve this situation with open/write/close using?

2 REPLIES
AlexanderM
Advisor

Re: Shareable writing into file

I've got some hurry with it. I've found the post with linked issue.

If the problem and the solution is identical I'll delete this one.

AlexanderM
Advisor
Solution

Re: Shareable writing into file

solution


 logFile = open(stampedPath.ptr, O_WRONLY | O_APPEND | O_CREAT, 0666
#ifdef VAX
                 ,"shr = del, get, put, upd", "ctx = stm", "ctx = bin"
#endif