Python C program subprocess hangs at “for line in iter”

后端 未结 3 2074
轻奢々
轻奢々 2020-11-22 05:12

Ok so I\'m trying to run a C program from a python script. Currently I\'m using a test C program:

#include 

int main() {
while (1) {
    prin         


        
3条回答
  •  攒了一身酷
    2020-11-22 05:58

    Your program isn't hung, it just runs very slowly. Your program is using buffered output; the "2000\n" data is not being written to stdout immediately, but will eventually make it. In your case, it might take BUFSIZ/strlen("2000\n") seconds (probably 1638 seconds) to complete.

    After this line:

    printf("2000\n");
    

    add

    fflush(stdout);
    

提交回复
热议问题