open(2) says that a third argument `mode' is to be provided to `open'
when O_CREAT is specified in the flags.
The specified mode is then combined with the umask to mount the
permissions for the newly created file (for future accesses). Right now
these permissions are none.
So we have to specify a set of reasonable permissions.
What about this:
open (handler, flags_for_open,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
Note that the `mode' third argument to `open' is ignored if O_CREAT is
not in `flags'.
WDYT?