Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize the endpoint for attach before calling fork. #89

Merged
merged 1 commit into from
Nov 29, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/conmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -1480,6 +1480,20 @@ int main(int argc, char *argv[])
add_argv(runtime_argv, opt_cid, NULL);
end_argv(runtime_argv);

/* Setup endpoint for attach */
_cleanup_free_ char *attach_symlink_dir_path = NULL;
if (opt_bundle_path != NULL) {
attach_symlink_dir_path = setup_attach_socket();
dummyfd = setup_terminal_control_fifo();
setup_console_fifo();

if (opt_attach) {
ndebug("sending attach message to parent");
write_sync_fd(attach_pipe_fd, 0, NULL);
ndebug("sent attach message to parent");
}
}

sigset_t mask, oldmask;
if ((sigemptyset(&mask) < 0) || (sigaddset(&mask, SIGTERM) < 0) || (sigaddset(&mask, SIGQUIT) < 0) || (sigaddset(&mask, SIGINT) < 0)
|| sigprocmask(SIG_BLOCK, &mask, &oldmask) < 0)
Expand Down Expand Up @@ -1588,20 +1602,6 @@ int main(int argc, char *argv[])
if (slavefd_stderr > -1)
close(slavefd_stderr);

/* Setup endpoint for attach */
_cleanup_free_ char *attach_symlink_dir_path = NULL;
if (opt_bundle_path != NULL) {
attach_symlink_dir_path = setup_attach_socket();
dummyfd = setup_terminal_control_fifo();
setup_console_fifo();

if (opt_attach) {
ndebug("sending attach message to parent");
write_sync_fd(attach_pipe_fd, 0, NULL);
ndebug("sent attach message to parent");
}
}

if (csname != NULL) {
g_unix_fd_add(console_socket_fd, G_IO_IN, terminal_accept_cb, csname);
/* Process any SIGCHLD we may have missed before the signal handler was in place. */
Expand Down