Re: XForms: problem executing a binary file from Xforms

Steve Lamont (spl@szechuan.ucsd.edu)
Fri, 13 Nov 98 09:01:47 PST

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

> I have only the executable version of this file and not the source.
> I set the options in a window and I have to run the file in the form:
> PRG PARAM1 PARAM2 PARAM3=20
> where PARAM1, 2, 3 are set as above.
> Now, I tried with the function execve but this kills the interface as =
> well.
> Any idea?

I'm not sure what you mean when you say "kills the interface." Do you
mean the interface disappears.

This is perhaps a little basic but are you doing a fork() before you
execve()? If you aren't then execve() replaces the calling executable
with the new one, which would cause the interface to disappear?

The standard way of spawning a subprocess is

if ( fork() == 0 )
execve( ... );

fork() creates an exact copy of the process (with some minor but
significant exceptions). It returns 0 to the child process and a
process id of the child to the parent. You generally perform the
execve() in the child process, replacing it with the new program.

For further elaboration on this, see the Stevens book _Advanced
Programming in the UNIX Environment_ or some other comparable
reference.

I should also mention that it is the kiss of death to execute any
XForms function calls in the child process before you do the
execve(). This will produce the dreaded and mysterious Xlib asynch
error -- messages between client and server are sequence numbered and
Xlib (and hence XForms) will become badly confused if this happens.

spl

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