Re: XForms: Problem understanding fl_exe_command

Ravi Mehrotra (ravi@csnpl.ren.nic.in)
Wed, 7 Jul 1999 09:10:04 +0530 (IST)

# To subscribers of the xforms list from Ravi Mehrotra <ravi@csnpl.ren.nic.in> :

Dear Steve,

Thanks for your suggestions. I tried out your workaround. I am afraid, I still
cannot make it work. Even after the mcopy finishes, the cmd_status remains 0
and the program trapped in the for{;;} loop. Is there something wrong with the
fl_exe_command itself in the NONBLOCK MODE ?

Ravi Mehrotra
National Physical Laboratory
New Delhi, India

>
> > I do not quite know how fl_exe_command works. The following piece of code
> > gives me problems. I am using XForms 0.89 on a Pentium Pro machine running
> > Linux 2.0.35.
>
> Methinks that fl_check_command() is broken, at least on the platforms I
> could try it on. TC?
>
> Use waitpid(). Here's a workaround:
>
> #include <sys/types.h>
> #include <sys/wait.h>
>
> #define NONBLOCK 0
> #define BLOCK 1
>
> long pid;
> FL_OBJECT *status;
>
> pid=fl_exe_command("mcopy -n a:file", NONBLOCK);
> for (;;) {
>
> int cmd_status;
>
> waitpid( pid, &cmd_status, WNOHANG );
>
> fl_addto_browser_chars(status,".");
> if ( cmd_status ) {
> fl_end_command(pid);
> break;
> }
> sleep(1);
> }
>
> You may want to check the return code from waitpid() for errors. You
> may also want to call fl_check_forms() in the loop to cause the
> browser to properly update.
>
> Even though fl_end_command() duplicates the waitpid(), you should
> still call it, since it does other necessary cleanup.
>
> spl
> _________________________________________________
> To unsubscribe, send the message "unsubscribe" to
> xforms-request@bob.usuhs.mil or see
> http://bob.usuhs.mil/mailserv/xforms.html
> XForms Home Page: http://bragg.phys.uwm.edu/xforms
> List Archive: http://bob.usuhs.mil/mailserv/list-archives/
>

_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuhs.mil or see
http://bob.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuhs.mil/mailserv/list-archives/