mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-22 22:56:29 +00:00
use a second fork to avoid a terminal
after the setsid() we are the process leader. And as a process leader we are able to open a new terminal, even if we currently don't own one. So we do another fork and do not call setsid() and not become a process leader to avoid that.
This commit is contained in:
18
repmgrd.c
18
repmgrd.c
@@ -230,6 +230,24 @@ main(int argc, char **argv)
|
||||
log_err("Error in setsid(): %s\n", strerror(errno));
|
||||
exit(ERR_SYS_FAILURE);
|
||||
}
|
||||
|
||||
/* ensure that we are no longer able to open a terminal */
|
||||
pid = fork();
|
||||
|
||||
if(pid == -1) /* error case */
|
||||
{
|
||||
log_err("Error in fork(): %s\n", strerror(errno));
|
||||
exit(ERR_SYS_FAILURE);
|
||||
break;
|
||||
}
|
||||
|
||||
if (pid != 0) /* parent process */
|
||||
{
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* a child just flows along */
|
||||
|
||||
break;
|
||||
|
||||
default: /* parent process */
|
||||
|
||||
Reference in New Issue
Block a user