mirror of
https://github.com/samba-team/samba.git
synced 2025-08-02 00:22:11 +03:00
s3:smbd: let smbd/nmbd/winbindd child processes terminate if the parent process died.
This applies to all child processes making use of reinit_after_fork(). It is implemented by establishing a pipe between parent and child. The child watches for EOF on the read end of the pipe, indidcating an exited parent. Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
This commit is contained in:
@ -57,6 +57,8 @@ struct smbd_parent_context {
|
||||
/* the list of current child processes */
|
||||
struct smbd_child_pid *children;
|
||||
size_t num_children;
|
||||
/* pipe for detecting death of parent process in child: */
|
||||
int child_pipe[2];
|
||||
|
||||
struct timed_event *cleanup_te;
|
||||
};
|
||||
@ -1231,6 +1233,17 @@ extern void build_options(bool screen);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Do not initialize the parent-child-pipe before becoming
|
||||
* a daemon: this is used to detect a died parent in the child
|
||||
* process.
|
||||
*/
|
||||
status = init_before_fork();
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
DEBUG(0, ("init_before_fork failed: %s\n", nt_errstr(status)));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
smbd_server_conn->msg_ctx = msg_ctx;
|
||||
|
||||
parent = talloc_zero(ev_ctx, struct smbd_parent_context);
|
||||
|
Reference in New Issue
Block a user