struct timeval next_callback_time;
- unsigned int isterm:1; /* is stdin terminal? */
+ unsigned int isterm:1, /* is stdin terminal? */
+ keep_slave_echo:1; /* keep ECHO on stdin */
};
void ul_pty_init_debug(int mask);
struct ul_pty *ul_new_pty(int is_stdin_tty);
void ul_free_pty(struct ul_pty *pty);
+void ul_pty_keep_slave_echo(struct ul_pty *pty, int enable);
int ul_pty_get_delivered_signal(struct ul_pty *pty);
void ul_pty_set_callback_data(struct ul_pty *pty, void *data);
free(pty);
}
+void ul_pty_keep_slave_echo(struct ul_pty *pty, int enable)
+{
+ assert(pty);
+ pty->keep_slave_echo = enable ? 1 : 0;
+}
int ul_pty_get_delivered_signal(struct ul_pty *pty)
{
if (!rc) {
tcgetattr(pty->slave, &slave_attrs);
- slave_attrs.c_lflag &= ~ECHO;
- tcsetattr(pty->slave, TCSANOW, &slave_attrs);
+ if (!pty->keep_slave_echo) {
+ slave_attrs.c_lflag &= ~ECHO;
+ tcsetattr(pty->slave, TCSANOW, &slave_attrs);
+ }
} else
goto done;
}
if (!ctl.pty)
err(EXIT_FAILURE, "failed to allocate PTY handler");
+ if (!ctl.isterm)
+ /* We keep ECHO flag for 'echo "date" | script' otherwise the
+ * input is no visible (output is completely comtroled by
+ * shell/command, we do not write anything there).
+ */
+ ul_pty_keep_slave_echo(ctl.pty, 1);
+
ul_pty_set_callback_data(ctl.pty, (void *) &ctl);
cb = ul_pty_get_callbacks(ctl.pty);
cb->child_die = callback_child_die;
shname = strrchr(shell, '/');
shname = shname ? shname + 1 : shell;
- if (command)
- execl(shell, shname, "-c", command, NULL);
- else
- execl(shell, shname, "-i", NULL);
+ if (access(shell, X_OK) == 0) {
+ if (command)
+ execl(shell, shname, "-c", command, NULL);
+ else
+ execl(shell, shname, "-i", NULL);
+ } else {
+ if (command)
+ execlp(shname, "-c", command, NULL);
+ else
+ execlp(shname, "-i", NULL);
+ }
+
err(EXIT_FAILURE, "failed to execute %s", shell);
break;
}