mirror of
https://passt.top/passt
synced 2025-05-23 09:45:34 +02:00
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>
This commit is contained in:
parent
57d8aa8ffe
commit
ba23b05545
3 changed files with 25 additions and 9 deletions
11
passt.c
11
passt.c
|
@ -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");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue