We need a proper way how to inform child (shell) that the game is
over. It seems the best is to send EOF to child rather than
immediately break PTY mainloop where we have poll(), because shell can
still produce data etc.
Signed-off-by: Karel Zak <kzak@redhat.com>
int ul_pty_get_childfd(struct ul_pty *pty);
void ul_pty_wait_for_child(struct ul_pty *pty);
pid_t ul_pty_get_child(struct ul_pty *pty);
+void ul_pty_write_eof_to_child(struct ul_pty *pty);
#endif /* UTIL_LINUX_PTY_H */
* maintains master+slave tty stuff within the session. Use pipe to write to
* pty and assume non-interactive (tee-like) behavior is NOT well supported.
*/
-static void write_eof_to_child(struct ul_pty *pty)
+void ul_pty_write_eof_to_child(struct ul_pty *pty)
{
unsigned int tries = 0;
struct pollfd fds[] = {
DBG(IO, ul_debugobj(pty, " ignore FD"));
pfd[i].fd = -1;
if (i == POLLFD_STDIN) {
- write_eof_to_child(pty);
+ ul_pty_write_eof_to_child(pty);
DBG(IO, ul_debugobj(pty, " ignore STDIN"));
}
}
struct timeval *delay;
rc = replay_get_next_step(ss->setup, "I", &ss->step);
+ if (rc == 1) {
+ ul_pty_write_eof_to_child(ss->pty);
+ rc = 0;
+ break;
+ }
if (rc)
break;