Skip to content

Commit

Permalink
Merge pull request containers#89 from DaanDeMeyer/reduce-error-impact
Browse files Browse the repository at this point in the history
Initialize the endpoint for attach before calling fork.
  • Loading branch information
rhatdan authored Nov 29, 2019
2 parents f6d23b5 + 5ae9942 commit 42bce45
Showing 1 changed file with 14 additions and 14 deletions.
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

0 comments on commit 42bce45

Please sign in to comment.