XForms: Problem understanding fl_exe_command

Ravi Mehrotra (ravi@csnpl.ren.nic.in)
Tue, 6 Jul 1999 08:58:08 +0530 (IST)

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

Hi,

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.

/*--------------------Problem Code---------------------------*/

#define NONBLOCK 0
#define BLOCK 1

long pid;
FL_OBJECT *status;

pid=fl_exe_command("mcopy -n a:file", NONBLOCK);
for (;;) {
fl_addto_browser_chars(status,".");
if (fl_check_command(pid) < 1) {
fl_end_command(pid);
break;
}
sleep(1);
}

/*--------------------------------------------------------------*/

I am copying a file from the floppy drive and adding a dot, once every
second, to a displayed line in a browser named status. The problem is
that even after the file copy is finished, which takes a minute or so,
I remain inside the loop for ever. I get a zombie process for mcopy as
seen in the ouput of the "ps ax" command.

The following code works, however, and As soon as the file copy is over
the timeout is removed.

/*--------------------OK Code---------------------------*/

#define NONBLOCK 0
#define BLOCK 1

long pid;
FL_OBJECT *status;

.
.
pid = fl_add_timeout(1000,add_dot,NULL);
fl_exe_command("mcopy -n a:file", BLOCK);
fl_remove_timeout(pid);
.
.

void add_dot(int id, void *data)
{
fl_addto_browser_chars(status,".");
pid = fl_add_timeout(1000,add_dot,NULL);
}

/*--------------------------------------------------------------*/

Thanks for any help.

Ravi Mehrotra
National Physical Laboratory
New Delhi, India
_________________________________________________
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/