From: Ben Gras Date: Fri, 5 Aug 2005 13:47:12 +0000 (+0000) Subject: pty select test X-Git-Tag: v3.1.0~429 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/Bv9ARM.ch11.html?a=commitdiff_plain;h=2888e14ed80b502586fe80a0dfb8328bfa510630;p=minix.git pty select test --- 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;