Skip to content
  • Kyle Evans's avatar
    kern_shm_open: push O_CLOEXEC into caller control · b5a7ac99
    Kyle Evans authored
    The motivation for this change is to allow wrappers around shm to be written
    that don't set CLOEXEC. kern_shm_open currently accepts O_CLOEXEC but sets
    it unconditionally. kern_shm_open is used by the shm_open(2) syscall, which
    is mandated by POSIX to set CLOEXEC, and CloudABI's sys_fd_create1().
    Presumably O_CLOEXEC is intended in the latter caller, but it's unclear from
    the context.
    
    sys_shm_open() now unconditionally sets O_CLOEXEC to meet POSIX
    requirements, and a comment has been dropped in to kern_fd_open() to explain
    the situation and add a pointer to where O_CLOEXEC setting is maintained for
    shm_open(2) correctness. CloudABI's sys_fd_create1() also unconditionally
    sets O_CLOEXEC to match previous behavior.
    
    This also has the side-effect of making flags correctly reflect the
    O_CLOEXEC status on this fd for the rest of kern_shm_open(), but a
    glance-over leads me to believe that it didn't really matter.
    
    Reviewed by:	kib, markj
    MFC after:	1 week
    Differential Revision:	https://reviews.freebsd.org/D21119
    b5a7ac99