popen ...

T.C. Zhao svec5 at menudo.uh.edu
Thu Jun 20 10:45:07 AEST 1991


I have read the popen man page many times, but still do not
quite understand how it should behave. Consider the following
code:

     ....
     case 4:
       if(!(fp = popen("more","w"))
         fp = stdout;
       lots_of_output_using_fprintf(fp...)_fputs(..,fp)_with_error_check
       if(fp!=stdout) pclose(fp);
       break;
    case 5:

everything seems working ok except when more quits prematurely(q),
the program exits. I do not think this is the way popen supposed to
work, but I would like to make sure.( smell bugs in the program
somewhere.) The other question is  how to catch the premature exit 
of more in the program (broken pipe?), checking fprintf return
does not seem do the trick.

Thanks in advance.



More information about the Comp.unix.programmer mailing list