Re: XForms: Problem understanding fl_exe_command

Steve Lamont (spl@szechuan.ucsd.edu)
Wed, 7 Jul 99 06:36:50 PDT

# To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont) :

> 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 ?

There may possibly be something wrong with fl_exe_command() (though I
don't think so), but there is definitely something wrong with the way
I read manual pages. (Gotta get my eyes tested!)

The workaround should be

#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;

fl_addto_browser_chars(status,".");
if ( waitpid( pid, &cmd_status, WNOHANG ) == pid ) {

fl_end_command(pid);
break;

}
sleep(1);
}

You may want to check the manual page for waitpid(2) just to be sure
that I haven't screwed up somewhere else. Again, you may wish to
check the value of `cmd_status' upon completion. Refer to the manual
page for instructions on how to parse it.

This will teach me to try to whip out answers while on the telephone.

A big "D'oh" for spl.

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/