jorton 2002/11/27 04:30:18
Modified: test proc_child.c
Log:
Fix to not assume input is NUL-terminated.
Revision Changes Path
1.2 +5 -3 apr/test/proc_child.c
Index: proc_child.c
===================================================================
RCS file: /home/cvs/apr/test/proc_child.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- proc_child.c 26 Nov 2002 16:09:56 -0000 1.1
+++ proc_child.c 27 Nov 2002 12:30:18 -0000 1.2
@@ -8,9 +8,11 @@
int main(void)
{
char buf[256];
-
- read(STDIN_FILENO, buf, 256);
- fprintf(stdout, "%s", buf);
+ ssize_t bytes;
+
+ bytes = read(STDIN_FILENO, buf, 256);
+ if (bytes > 0)
+ write(STDOUT_FILENO, buf, bytes);
return 0; /* just to keep the compiler happy */
}