/* echoline.c - Echo to stdout each line read from stdin */ #include #include #include #define LINEMAX 256 int main() { char line[LINEMAX]; int n; for ( ; ; ) { /* on the socket pair we cannot use printf, scanf, etc. */ /* For printf, scanf, etc. we need to have a pseudoterminal. */ n = read(STDIN_FILENO, line, LINEMAX-1); if (n < 0) break; line[n] = '\0'; write(STDOUT_FILENO, line, n); } return 0; }