I have the following C application
#include <stdio.h>
int main(void)
{
    printf("hello world\n");
    /* Go into an infinite loop here. */
    while(1);
    return 0;
}
And I have the following python code.
import subprocess
import time
import pprint
def run():
    command = ["./myapplication"]
    process = subprocess.Popen(command, stdout=subprocess.PIPE)
    try:
        while process.poll() is None:
            # HELP: This call blocks...
            for i in  process.stdout.readline():
                print(i)
    finally:
        if process.poll() is None:
            process.kill()
if __name__ == "__main__":
    run()
When I run the python code, the stdout.readline or even stdout.read blocks.
If I run the application using subprocess.call(program) then I can see "hello world" in stdout.
How can I read input from stdout with the example I have provided?
Note: I would not want to modify my C program. I have tried this on both Python 2.7.17 and Python 3.7.5 under Ubuntu 19.10 and I get the same behaviour. Adding bufsize=0 did not help me.
 
     
    