Skip to content

Commit

Permalink
daemon: fix pid value by using getpid() in the child process
Browse files Browse the repository at this point in the history
Previously ctx.pid was getting it's value indirectly from fork(),
which is always zero in the child process.

Fixed a bug introduced in 2b3ca2b.

Signed-off-by: Egor Ignatov <egori@altlinux.org>
  • Loading branch information
Blarse authored and vathpela committed Nov 14, 2023
1 parent 013cc9a commit d4cede0
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -1191,10 +1191,8 @@ daemonize(cms_context *cms_ctx, char *certdir, int do_fork)
sleep(2);
return 0;
}
ctx.pid = pid;
} else {
ctx.pid = getpid();
}
ctx.pid = getpid();
write_pid_file(ctx.pid);
ctx.backup_cms->log(ctx.backup_cms, ctx.priority|LOG_NOTICE,
"pesignd starting (pid %d)", ctx.pid);
Expand Down

0 comments on commit d4cede0

Please sign in to comment.