ply terminal session: Drop ply_terminal_session_run, this is a feature from a bygone time which is no longer in use

This commit is contained in:
ZhaoQiang 2019-07-11 21:53:31 +00:00 committed by Ray Strode
parent 935938221e
commit c6a2e1a2a6
2 changed files with 0 additions and 80 deletions

View file

@ -263,80 +263,6 @@ open_pseudoterminal (ply_terminal_session_t *session)
return true;
}
bool
ply_terminal_session_run (ply_terminal_session_t *session,
ply_terminal_session_flags_t flags,
ply_terminal_session_begin_handler_t begin_handler,
ply_terminal_session_output_handler_t output_handler,
ply_terminal_session_hangup_handler_t hangup_handler,
void *user_data)
{
pid_t pid;
bool run_in_parent, look_in_path, should_redirect_console;
assert (session != NULL);
assert (session->loop != NULL);
assert (!session->is_running);
assert (session->hangup_handler == NULL);
run_in_parent = (flags & PLY_TERMINAL_SESSION_FLAGS_RUN_IN_PARENT) != 0;
look_in_path = (flags & PLY_TERMINAL_SESSION_FLAGS_LOOK_IN_PATH) != 0;
should_redirect_console =
(flags & PLY_TERMINAL_SESSION_FLAGS_REDIRECT_CONSOLE) != 0;
ply_trace ("creating terminal device");
if (!open_pseudoterminal (session))
return false;
ply_trace ("done creating terminal device");
if (should_redirect_console)
ply_trace ("redirecting system console to terminal device");
if (should_redirect_console &&
!ply_terminal_session_redirect_console (session)) {
ply_save_errno ();
close_pseudoterminal (session);
ply_restore_errno ();
return false;
}
if (should_redirect_console)
ply_trace ("done redirecting system console to terminal device");
ply_trace ("creating subprocess");
pid = fork ();
if (pid < 0) {
ply_save_errno ();
ply_terminal_session_unredirect_console (session);
close_pseudoterminal (session);
ply_restore_errno ();
return false;
}
if (((pid == 0) && run_in_parent) ||
((pid != 0) && !run_in_parent)) {
session->is_running = true;
session->output_handler = output_handler;
session->hangup_handler = hangup_handler;
session->user_data = user_data;
ply_terminal_session_start_logging (session);
return true;
}
if (begin_handler != NULL) {
ply_trace ("running 'begin handler'");
begin_handler (user_data, session);
ply_trace ("ran 'begin handler'");
}
ply_trace ("beginning session");
ply_terminal_session_execute (session, look_in_path);
_exit (errno);
return false;
}
bool
ply_terminal_session_attach (ply_terminal_session_t *session,
ply_terminal_session_flags_t flags,

View file

@ -54,12 +54,6 @@ ply_terminal_session_t *ply_terminal_session_new (const char *const *argv);
void ply_terminal_session_free (ply_terminal_session_t *session);
void ply_terminal_session_attach_to_event_loop (ply_terminal_session_t *session,
ply_event_loop_t *loop);
bool ply_terminal_session_run (ply_terminal_session_t *session,
ply_terminal_session_flags_t flags,
ply_terminal_session_begin_handler_t begin_handler,
ply_terminal_session_output_handler_t output_handler,
ply_terminal_session_hangup_handler_t done_handler,
void *user_data);
bool ply_terminal_session_attach (ply_terminal_session_t *session,
ply_terminal_session_flags_t flags,