Post History
A system daemon needs to create several files under /run/program-name/ (and possibly other subdirs of that). They are the PID file, and at least one Unix socket file (but maybe more). The FHS spe...
#3: Post edited
- A system daemon needs to create several files under `/run/program-name/` (and possibly other subdirs of that). They are the PID file, and at least one Unix socket file (but maybe more). The FHS specifies that those files go there, under a `/run` subdir: <https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s15.html#runRequirements>. (In some Unix systems, it would still be `/var/run` instead of `/run`, but the same question applies.)
But who is responsible for the creation of the dir(s)? Should the daemon call the equivalent of `mkdir -p` right before `open(..., O_CREAT)` or *bind(2)*? Or should the sysadmin make sure that the directory exist before the daemon runs, by configuring *systemd-tmpfiles(8)* or equivalent (e.g., an rc script, or the docker entrypoint), and the daemon assume that the directory exists (and fail if it doesn't)? Or both (i.e., the sysadmin makes sure the dir exists, but the daemon still calls *mkdir(2)* just in case to avoid failing)?
- A system daemon needs to create several files under `/run/program-name/` (and possibly other subdirs of that). They are the PID file, and at least one Unix socket file (but maybe more). The FHS specifies that those files go there, under a `/run` subdir: <https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s15.html#runRequirements>. (In some Unix systems, it would still be `/var/run` instead of `/run`, but the same question applies.)
- But who is responsible for the creation of the dir(s)? Should the daemon call the equivalent of `mkdir -p` right before `open(..., O_CREAT)` or *bind(2)*? Or should the sysadmin make sure that the directory exists before the daemon runs, by configuring *systemd-tmpfiles(8)* or equivalent (e.g., an rc script, or the docker entrypoint), and the daemon assume that the directory exists (and fail if it doesn't)? Or both (i.e., the sysadmin makes sure the dir exists, but the daemon still calls *mkdir(2)* just in case to avoid failing)?
#2: Post edited
A system daemon needs to create several files under `/run/program-name/` (and possibly other subdirs of that). They are the PID file, and at least one Unix socket file (but maybe more). The FHS specifies that those files go there, under a `/run` subdir: <https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s15.html#runRequirements>. (In some Unix systems, it would still be `/var/run`, but the same question applies.)- But who is responsible for the creation of the dir(s)? Should the daemon call the equivalent of `mkdir -p` right before `open(..., O_CREAT)` or *bind(2)*? Or should the sysadmin make sure that the directory exist before the daemon runs, by configuring *systemd-tmpfiles(8)* or equivalent (e.g., an rc script, or the docker entrypoint), and the daemon assume that the directory exists (and fail if it doesn't)? Or both (i.e., the sysadmin makes sure the dir exists, but the daemon still calls *mkdir(2)* just in case to avoid failing)?
- A system daemon needs to create several files under `/run/program-name/` (and possibly other subdirs of that). They are the PID file, and at least one Unix socket file (but maybe more). The FHS specifies that those files go there, under a `/run` subdir: <https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s15.html#runRequirements>. (In some Unix systems, it would still be `/var/run` instead of `/run`, but the same question applies.)
- But who is responsible for the creation of the dir(s)? Should the daemon call the equivalent of `mkdir -p` right before `open(..., O_CREAT)` or *bind(2)*? Or should the sysadmin make sure that the directory exist before the daemon runs, by configuring *systemd-tmpfiles(8)* or equivalent (e.g., an rc script, or the docker entrypoint), and the daemon assume that the directory exists (and fail if it doesn't)? Or both (i.e., the sysadmin makes sure the dir exists, but the daemon still calls *mkdir(2)* just in case to avoid failing)?
#1: Initial revision
Who creates subdirs under `/run`?
A system daemon needs to create several files under `/run/program-name/` (and possibly other subdirs of that). They are the PID file, and at least one Unix socket file (but maybe more). The FHS specifies that those files go there, under a `/run` subdir: <https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s15.html#runRequirements>. (In some Unix systems, it would still be `/var/run`, but the same question applies.) But who is responsible for the creation of the dir(s)? Should the daemon call the equivalent of `mkdir -p` right before `open(..., O_CREAT)` or *bind(2)*? Or should the sysadmin make sure that the directory exist before the daemon runs, by configuring *systemd-tmpfiles(8)* or equivalent (e.g., an rc script, or the docker entrypoint), and the daemon assume that the directory exists (and fail if it doesn't)? Or both (i.e., the sysadmin makes sure the dir exists, but the daemon still calls *mkdir(2)* just in case to avoid failing)?