I have a Bash script work.sh that get something from STDIN and echo it to STDOUT.
I also have a C programme, return_input, that also get something from STDIN and printf to STDOUT
But when I chain them this way:
./work.sh |./return_input
printf in return_input only output to screen when exiting. Why?
Simplified:
[root@ test]# cat work.sh
#!/bin/bash
for i in {1..5}
do
echo test
read
done
Output of cat return_input.c,
#include <stdio.h>
void return_input (void){
char array[30];
gets (array);
printf("%s\n", array);
printf("%#p\n", *(long *)(array+40));
}
main() {
while(1 == 1)return_input();
return 0;
}