c - Is it safe to write to a descriptor after ENOSPC -


imagine situation:

  • one process (a) continuously writes data disk creating large files, appends data using separate write() commands
  • another process (b), continuously deletes files disk
  • the assumption (b) deletes data fast enough (a) has room write. however, not guaranteed.
  • imagine (a) attempts write open descriptor , gets enospc. since (a) knows (b) should make room, (a) retry write.

question: safe (a), after receiving enospc, attempt write on same descriptor got enospc on? couldn't find information it, , wonder if might depend on things os, filesystem etc.

there's nothing special enospc. indicates write failed, , reason why failed has device not having enough free space complete operation. doesn't leave file descriptor in bad or undefined state. file descriptor remains in same state before call. can safely keep trying want.

note should prepared short writes. if write system call doesn't have enough space complete operation instead of failing enospc, can write as can , return successfully. in case return value indicate actual number of bytes written.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -