diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2024-05-22 19:50:58 +0200 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2024-05-23 16:43:13 +0200 |
commit | ba23b05545e1e316235fad7a66f3cfd643c22146 (patch) | |
tree | cd590216a2fab87eea2f109ed28eadb16a551a9e /passt.c | |
parent | 57d8aa8ffefcc226c5c3179e4a8d346cbe61e865 (diff) | |
download | passt-ba23b05545e1e316235fad7a66f3cfd643c22146.tar passt-ba23b05545e1e316235fad7a66f3cfd643c22146.tar.gz passt-ba23b05545e1e316235fad7a66f3cfd643c22146.tar.bz2 passt-ba23b05545e1e316235fad7a66f3cfd643c22146.tar.lz passt-ba23b05545e1e316235fad7a66f3cfd643c22146.tar.xz passt-ba23b05545e1e316235fad7a66f3cfd643c22146.tar.zst passt-ba23b05545e1e316235fad7a66f3cfd643c22146.zip |
passt, util: Move opening of PID file to its own function
We won't call it from main() any longer: move it.
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
Diffstat (limited to 'passt.c')
-rw-r--r-- | passt.c | 11 |
1 files changed, 2 insertions, 9 deletions
@@ -199,7 +199,7 @@ void exit_handler(int signal) */ int main(int argc, char **argv) { - int nfds, i, devnull_fd = -1, pidfile_fd = -1; + int nfds, i, devnull_fd = -1, pidfile_fd; struct epoll_event events[EPOLL_EVENTS]; char *log_name, argv0[PATH_MAX], *name; struct ctx c = { 0 }; @@ -299,14 +299,7 @@ int main(int argc, char **argv) } } - if (*c.pid_file) { - if ((pidfile_fd = open(c.pid_file, - O_CREAT | O_TRUNC | O_WRONLY | O_CLOEXEC, - S_IRUSR | S_IWUSR)) < 0) { - perror("PID file open"); - exit(EXIT_FAILURE); - } - } + pidfile_fd = pidfile_open(c.pid_file); if (isolate_prefork(&c)) die("Failed to sandbox process, exiting"); |