Refactor the pty implementation

This commit is contained in:
Jianfeng Jiang
2023-08-28 14:28:23 +08:00
committed by Tate, Hongliang Tian
parent 40056f0692
commit 038c19b693
10 changed files with 396 additions and 443 deletions

View File

@ -15,8 +15,6 @@ int main() {
exit(EXIT_FAILURE);
}
printf("master fd: %d\n", master);
printf("slave fd: %d\n", slave);
printf("slave name: %s\n", name);
// Set pty slave terminal attributes
@ -33,7 +31,7 @@ int main() {
char buf[256];
ssize_t n = read(master, buf, sizeof(buf));
if (n > 0) {
printf("read %ld bytes from slave: %.*s\n", n, (int)n, buf);
printf("read %ld bytes from slave: %.*s", n, (int)n, buf);
}
// Write to pty master
@ -43,7 +41,7 @@ int main() {
char nbuf[256];
ssize_t nn = read(slave, nbuf, sizeof(nbuf));
if (nn > 0) {
printf("read %ld bytes from master: %.*s\n", nn, (int)nn, nbuf);
printf("read %ld bytes from master: %.*s", nn, (int)nn, nbuf);
}
close(master);

View File

@ -6,7 +6,7 @@ SCRIPT_DIR=/regression
cd ${SCRIPT_DIR}/..
echo "Running tests......"
tests="hello_world/hello_world fork/fork execve/execve fork_c/fork signal_c/signal_test pthread/pthread_test hello_pie/hello"
tests="hello_world/hello_world fork/fork execve/execve fork_c/fork signal_c/signal_test pthread/pthread_test hello_pie/hello pty/open_pty"
for testcase in ${tests}
do
echo "Running test ${testcase}......"