/* demonstrate polling wakeup */ #include #include #include #include #include #include #include #include static int master, slave; int main(void) { int r; r = openpty(&master,&slave,0,0,0); fprintf(stdout,"openpty=%d master=%d slave=%d\n", r, master, slave); assert(!r); r = fcntl(master, F_GETFL); assert(r>=0); r = fcntl(master, F_SETFL, r | O_NONBLOCK); char buf[400]; int i; for (i=0; i=0 && r<=sizeof(buf)); fprintf(stdout,"wrote %d\n",r); } }