writing zero bytes in bash

Miloslav Trmac mitr at volny.cz
Sat Feb 26 10:39:16 UTC 2005

On Sat, Feb 26, 2005 at 06:32:13PM +1100, Russell Coker wrote:
> To unset the fscreate or exec context you have to write zero bytes 
> to /proc/self/attr/fscreate or /proc/self/attr/exec respectively.
I personally think this is the problem - no interface should require writing
0 bytes.

To quote the POSIX spec:
| Before  any  action described below is taken, and if nbyte is zero and
| the file is a regular file, the write() function may detect and return
| errors  as  described  below.  In  the  absence of errors, or if error
| detection is not performed, the write() function shall return zero and
| have no other results.  If nbyte is zero and the file is not a regular
| file, the results are unspecified.

Files in /proc _are_ regular files, as far as stat() is concerned, so
I don't think you can require that portable programs give you the
possibility to write 0 bytes to these files.

More information about the fedora-devel-list mailing list