XForms: Plumbing

From: rob.carpenter@lmco.com
Date: Fri Jun 16 2000 - 10:51:25 EDT

  • Next message: Paolo Prandini: "R: R: R: XForms: More on the subject of threads"

    # To subscribers of the xforms list from rob.carpenter@lmco.com :

    I am trying to connect a pipe to an external process and

    print the stdout
    and stderr of the process to my own browser

    (not the Command Log).

    following example is one way I tried it, but the callback

    pipe_cb seems to
    be invoked repeatedly with the last line

    that was output from the external
    process even though the

    pipe is at end of file. Is that the correct

    Is there something wrong or is there another better way

    accomplishing this task?

    Xforms: v0.89

    OS: Dec Unix


    #include <stdio.h>


    #include "forms.h"

    FILE *fp;

    void pipe_cb(int fd, void


        static char str[256];

        static i = 0;

        fgets(str, 256,

        if (feof(fp))

            printf("eof ");

        /* this line would be
    output to browser */

        printf("%s %d\n", str, i++);fflush(stdout);

    (i > 10)



    int main(int argc, char *argv[])



        int fd;

        fl_initialize(&argc, argv, "Pipe Form", 0,

        simpleform = fl_bgn_form(FL_UP_BOX,230,160);


    if ((fp = popen("echo Hello", "r")) == NULL)


    opening pipe\n");



        fd = fileno(fp);

    fl_add_io_callback(fd, FL_READ, (FL_IO_CALLBACK)pipe_cb, NULL);

    fl_show_form(simpleform, FL_PLACE_MOUSE, FL_NOBORDER, "Pipe Test");




    To unsubscribe, send the message "unsubscribe" to
    xforms-request@bob.usuhs.mil or see
    XForms Home Page: http://world.std.com/~xforms
    List Archive: http://bob.usuhs.mil/mailserv/list-archives/

    This archive was generated by hypermail 2b29 : Fri Jun 16 2000 - 10:56:59 EDT