0

I have a c++ program that is split into pbs jobs and is then submitted to a computing cluster. I want the output of each job to be written to the same file; I have tried appending the file but this leads to abunch of nonsense since the same file gets opened by each job so not every job gets to write all of its output to the file. I was wondering if there is a way to check whether or not a file is open or closed in another program?

P.S. I checked if there were any helpful answers about similar question and there were not so I felt the need to ask this version

Mike
  • 21
  • 1
  • 4
  • 2
    You should probably try [locking the file](https://stackoverflow.com/questions/1599459/optimal-lock-file-method) to avoid concurrent writes. – tadman Nov 01 '17 at 20:09
  • 1
    No way of doing this with C++ Standard Library - your OS may have features that support it. –  Nov 01 '17 at 20:10
  • This has little to do with the C++. More like consuming OS specific APIs. – Ron Nov 01 '17 at 20:13
  • What operating system and file system are you using? Some distributed file systems such as NFS support `flock`. – Dima Chubarov Nov 02 '17 at 04:47

0 Answers0