Skip to main content
replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
Source Link

I can think some possible causes.

  1. Your program writing the file read_data.txt, it locked the file exclusively, so curl couldn't open the file. In this case you can easily test with another program to just dump the contents using cat or tail
  2. While the file read_data.txt is getting more data, appending its contents, this is the point I'm not understanding why you didn't wait the file finished, the posted data is not complete, so your php program cannot translate them into json. Check your input from php side.

One possible solution is, rather than pouring the long&large data to the destination read_data.txt, you can just download it to a tmp file like read_data.x4GwkQ.txt and when you finishing the task, just rename(switch) it if you didn't lock it exclusively (O_EXCL in open function).

Or, just tie them up within an external lock file with flock. What Unix commands can be used as a semaphore/lock?What Unix commands can be used as a semaphore/lock?

I can think some possible causes.

  1. Your program writing the file read_data.txt, it locked the file exclusively, so curl couldn't open the file. In this case you can easily test with another program to just dump the contents using cat or tail
  2. While the file read_data.txt is getting more data, appending its contents, this is the point I'm not understanding why you didn't wait the file finished, the posted data is not complete, so your php program cannot translate them into json. Check your input from php side.

One possible solution is, rather than pouring the long&large data to the destination read_data.txt, you can just download it to a tmp file like read_data.x4GwkQ.txt and when you finishing the task, just rename(switch) it if you didn't lock it exclusively (O_EXCL in open function).

Or, just tie them up within an external lock file with flock. What Unix commands can be used as a semaphore/lock?

I can think some possible causes.

  1. Your program writing the file read_data.txt, it locked the file exclusively, so curl couldn't open the file. In this case you can easily test with another program to just dump the contents using cat or tail
  2. While the file read_data.txt is getting more data, appending its contents, this is the point I'm not understanding why you didn't wait the file finished, the posted data is not complete, so your php program cannot translate them into json. Check your input from php side.

One possible solution is, rather than pouring the long&large data to the destination read_data.txt, you can just download it to a tmp file like read_data.x4GwkQ.txt and when you finishing the task, just rename(switch) it if you didn't lock it exclusively (O_EXCL in open function).

Or, just tie them up within an external lock file with flock. What Unix commands can be used as a semaphore/lock?

Source Link
tsohr
  • 141
  • 3

I can think some possible causes.

  1. Your program writing the file read_data.txt, it locked the file exclusively, so curl couldn't open the file. In this case you can easily test with another program to just dump the contents using cat or tail
  2. While the file read_data.txt is getting more data, appending its contents, this is the point I'm not understanding why you didn't wait the file finished, the posted data is not complete, so your php program cannot translate them into json. Check your input from php side.

One possible solution is, rather than pouring the long&large data to the destination read_data.txt, you can just download it to a tmp file like read_data.x4GwkQ.txt and when you finishing the task, just rename(switch) it if you didn't lock it exclusively (O_EXCL in open function).

Or, just tie them up within an external lock file with flock. What Unix commands can be used as a semaphore/lock?