A
Allan Adler
In C, I can execute
system("gs gleep.ps");
and have C run a ghostscript program gleep.ps, which might ask for user
input and, when it gets it, take some actions and report back to the
C program. I think I can probably handle that last step by having ghostscript
write to a file and have the C program read the file.
That's ok for one interactive program. Suppose I want to have two or more
interactive programs running, along with possible interactive stuff done by
the C program itself. If I just execute a system command for each one, the
C program won't move past that system command until the program called by
that system command has terminated. How do I get it to start one program P1,
remain in communication with it, start another P2, remain in communication
with it, and meanwhile do its own thing which might also include asking
the user to do things and waiting for answers from the user?
My guess is that this has something to do with exec or execve, and maybe
with fork, and maybe with throw and catch and with message passing, stuff
that I've never understood and never used. What should I be reading that
explains what I need to know for this in words of one syllable.
I'm actually doing this under RedHat Linux, but since ANSI C is supposed to
be reasonably platform independent, that probably doesn't matter except in
the way that the calls are made to the operating system. The relevant concepts
and broad format should be pretty much the same, I would guess.
Here is a very concrete example. I want to have the C program run a
ghostscript program gleep.ps and a Maxima program gleep.mac and to remain
in communication with both of them them until they exit. How do I do that?
system("gs gleep.ps");
and have C run a ghostscript program gleep.ps, which might ask for user
input and, when it gets it, take some actions and report back to the
C program. I think I can probably handle that last step by having ghostscript
write to a file and have the C program read the file.
That's ok for one interactive program. Suppose I want to have two or more
interactive programs running, along with possible interactive stuff done by
the C program itself. If I just execute a system command for each one, the
C program won't move past that system command until the program called by
that system command has terminated. How do I get it to start one program P1,
remain in communication with it, start another P2, remain in communication
with it, and meanwhile do its own thing which might also include asking
the user to do things and waiting for answers from the user?
My guess is that this has something to do with exec or execve, and maybe
with fork, and maybe with throw and catch and with message passing, stuff
that I've never understood and never used. What should I be reading that
explains what I need to know for this in words of one syllable.
I'm actually doing this under RedHat Linux, but since ANSI C is supposed to
be reasonably platform independent, that probably doesn't matter except in
the way that the calls are made to the operating system. The relevant concepts
and broad format should be pretty much the same, I would guess.
Here is a very concrete example. I want to have the C program run a
ghostscript program gleep.ps and a Maxima program gleep.mac and to remain
in communication with both of them them until they exit. How do I do that?