From 2888e14ed80b502586fe80a0dfb8328bfa510630 Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Fri, 5 Aug 2005 13:47:12 +0000 Subject: [PATCH] pty select test --- test/select/Makefile | 1 + test/select/test14.c | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/test/select/Makefile b/test/select/Makefile index 4820b8703..08b0c3a58 100644 --- a/test/select/Makefile +++ b/test/select/Makefile @@ -36,3 +36,4 @@ test11: test11.c test12: test12.c test13a: test13a.c test13b: test13b.c +test14: test14.c diff --git a/test/select/test14.c b/test/select/test14.c index df64bdebf..d6af8de06 100644 --- a/test/select/test14.c +++ b/test/select/test14.c @@ -23,6 +23,8 @@ #include #include +char name[100]; + void pipehandler(int sig) { @@ -95,7 +97,8 @@ void do_parent(int pty_fds[]) while (1) { FD_ZERO(&fds_write); FD_SET(pty_fds[1], &fds_write); - printf("pid %d Waiting for pty ready to write...\n", getpid()); + printf("pid %d Waiting for pty ready to write on %s...\n", + getpid(), name); retval = select(pty_fds[1]+1, NULL, &fds_write, NULL, NULL); if (retval == -1) { perror("select"); @@ -131,15 +134,15 @@ void do_parent(int pty_fds[]) int main(int argc, char *argv[]) { - int pipes[2]; + int ptys[2]; int retval; int pid; - if(openpty(&pipes[0], &pipes[1], NULL, NULL, NULL) < 0) { + if(openpty(&ptys[0], &ptys[1], name, NULL, NULL) < 0) { perror("openpty"); return 1; } - sleep(50); + printf("Using %s\n", name); pid = fork(); if (pid == -1) { fprintf(stderr, "Error forking\n"); @@ -147,9 +150,9 @@ int main(int argc, char *argv[]) } if (pid == 0) /* child proc */ - do_child(pipes); + do_child(ptys); else - do_parent(pipes); + do_parent(ptys); /* not reached */ return 0; -- 2.44.0