Skip to content
Snippets Groups Projects
  • Max Melentiev's avatar
    1e509dde
    Enable support for NOTIFY_SOCKET in envs without systemd · 1e509dde
    Max Melentiev authored
    To make it possible to develop and test related features on
    systems without systemd.
    
    WITH_SYSTEMD cmake flag is used to generate systemd related files:
    unit, generator script, etc. To keep this behavior and make it possible
    to use NOTIFY_SOCKET without other systemd-related stuff,
    I added WITH_NOTIFY_SOCKET cmake flag.
    
    It also required some changes to support other OS:
    
    SOCK_CLOEXEC (not available on macOS) flag for socket()
    is replaced with `fcntl(fd, F_SETFD, FD_CLOEXEC)` which has the same effect.
    
    MSG_NOSIGNAL flag for sendmsg is also not available on macOS.
    However it has SO_NOSIGPIPE flag for setsockopt which disables SIGPIPE.
    So it requires different solution for different OS. Inspired by
    https://nwat.xyz/blog/2014/01/16/porting-msg_more-and-msg_nosigpipe-to-osx/
    
    Have to reduce send-buffer size to 4MB because larger values
    are not supported on macOS by default. This value should be enough
    for all systems because notification messages are usually less than 1KB.
    
    Fixes #4436
    1e509dde
    History
    Enable support for NOTIFY_SOCKET in envs without systemd
    Max Melentiev authored
    To make it possible to develop and test related features on
    systems without systemd.
    
    WITH_SYSTEMD cmake flag is used to generate systemd related files:
    unit, generator script, etc. To keep this behavior and make it possible
    to use NOTIFY_SOCKET without other systemd-related stuff,
    I added WITH_NOTIFY_SOCKET cmake flag.
    
    It also required some changes to support other OS:
    
    SOCK_CLOEXEC (not available on macOS) flag for socket()
    is replaced with `fcntl(fd, F_SETFD, FD_CLOEXEC)` which has the same effect.
    
    MSG_NOSIGNAL flag for sendmsg is also not available on macOS.
    However it has SO_NOSIGPIPE flag for setsockopt which disables SIGPIPE.
    So it requires different solution for different OS. Inspired by
    https://nwat.xyz/blog/2014/01/16/porting-msg_more-and-msg_nosigpipe-to-osx/
    
    Have to reduce send-buffer size to 4MB because larger values
    are not supported on macOS by default. This value should be enough
    for all systems because notification messages are usually less than 1KB.
    
    Fixes #4436