mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-01-23 10:16:41 +00:00
log: Write more details in write_pidfile
Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com> Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
This commit is contained in:
parent
7c6eb0b85c
commit
aab709b602
1 changed files with 17 additions and 4 deletions
21
criu/log.c
21
criu/log.c
|
|
@ -397,15 +397,28 @@ void print_on_level(unsigned int loglevel, const char *format, ...)
|
|||
|
||||
int write_pidfile(int pid)
|
||||
{
|
||||
int fd;
|
||||
int fd, ret, exit_code = -1;
|
||||
|
||||
fd = open(opts.pidfile, O_WRONLY | O_EXCL | O_CREAT, 0600);
|
||||
if (fd == -1) {
|
||||
pr_perror("Can't open %s", opts.pidfile);
|
||||
pr_perror("pidfile: Can't open %s", opts.pidfile);
|
||||
return -1;
|
||||
}
|
||||
|
||||
dprintf(fd, "%d", pid);
|
||||
ret = dprintf(fd, "%d", pid);
|
||||
if (ret < 0) {
|
||||
pr_perror("pidfile: Can't write pid %d to %s", pid, opts.pidfile);
|
||||
goto close;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
pr_err("pidfile: Can't write pid %d to %s\n", pid, opts.pidfile);
|
||||
goto close;
|
||||
}
|
||||
|
||||
pr_debug("pidfile: Wrote pid %d to %s (%d bytes)\n", pid, opts.pidfile, ret);
|
||||
exit_code = 0;
|
||||
close:
|
||||
close(fd);
|
||||
return 0;
|
||||
return exit_code;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue