In the my-daemon programs (here, I explicitly refer to ch10/my-daemon-v2.c), the syscall to umask(022) should either be used before creating the pidfile, or the permissions of the pidfile need to be set explicitly for the control client to work as described in the book.
Explanation
This is not the case if the root user uses a umask of e.g. 027 per default (via environment or similar), where the pidfile ends up with permissions 640 (rw-r-----), making it impossible for users other than root to use the control client for querying the status of the daemon.
Description
In the my-daemon programs (here, I explicitly refer to
ch10/my-daemon-v2.c
), the syscall toumask(022)
should either be used before creating the pidfile, or the permissions of the pidfile need to be set explicitly for the control client to work as described in the book.Explanation
This is not the case if the root user uses a umask of e.g. 027 per default (via environment or similar), where the pidfile ends up with permissions 640 (
rw-r-----
), making it impossible for users other than root to use the control client for querying the status of the daemon.Steps to reproduce: