Exclusive control between DataMagic and the user process
When needed, you can implement exclusive file control between DataMagic and a business application that you are creating, as follows:
In Windows, open and permit sharing of input and error files in DataMagic. Output files should be opened exclusively (write-protected) without using mutex objects to lock them. To implement exclusive control of output files in the business application, check the file access permission information before reading or writing.
In UNIX, use the lockf() function to lock input files, output files, and error files in DataMagic. (For details, see the online OS documentation.) The lockf() function can also be used to implement exclusive control of input and output files in the business application.
- Example of an exclusive control program (for UNIX/Linux):
-
#include <fcntl.h> #include <unistd.h> int main(void) { int fd; fd = open("outfile.dat", O_RDWR|O_CREAT, 0666); if (fd == -1){ perror("open"); return 1; } if (lockf(fd, F_LOCK, 0) == -1) { perror("lockf"); return 1; } /* * file read and/or file write */ lockf(fd, F_ULOCK, 0); close(fd); return 0; }