473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

system with several interactive programs


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?
--
Ignorantly,
Allan Adler <ar*@zurich.csail.mit.edu>
* Disclaimer: I am a guest and *not* a member of the MIT CSAIL. My actions and
* comments do not reflect in any way on MIT. Also, I am nowhere near Boston.
Nov 14 '05 #1
2 1685
On 04 Apr 2005 22:08:11 -0400, Allan Adler <ar*@nestle.csail.mit.edu>
wrote in comp.lang.c:

In C, I can execute

system("gs gleep.ps");
Indeed you can, and it might well do something that you want done on
your system. While the system() function is part of the standard C
library, the argument you pass to it and the results are completely
implementation-defined.
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 the only portable way to do it.

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?
Now you have passed beyond the boundaries offered by the standard C
language and library. Assuming that your platform supports concurrent
execution of multiple programs, an assumption that C does not make,
then you need to make use of extended features provided by your
platform.
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.
It might well have something to do with exec, ecexve, or fork, but
none of these are part of standard C. They are extensions on some
platforms, perhaps including yours.
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.
ISO C (ANSI is one of the national member bodies of ISO) is indeed
reasonably platform independent, but not in the way that you think. C
has no support at all for multiple processes or threads of execution.
The chip in your microwave oven doesn't provide such things.
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?


There is no way at all to do what you want in standard, that is
ISO/ANSI C. There is certainly a way that you can do it in Linux, but
platform specific extensions are not discussed here.

If you post this for the experts to see in
news:comp.os.linux.development.apps, I'm sure they'll be happy to help
you.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Nov 14 '05 #2

Thanks to Jack Klein <ja*******@spamcop.net> for his helpful comments
in reply to my ignorant questions.
If you post this for the experts to see in
news:comp.os.linux.development.apps, I'm sure they'll be happy to help
you.


Thanks, I'll go there.
--
Ignorantly,
Allan Adler <ar*@zurich.csail.mit.edu>
* Disclaimer: I am a guest and *not* a member of the MIT CSAIL. My actions and
* comments do not reflect in any way on MIT. Also, I am nowhere near Boston.
Nov 14 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Joerg Schuster | last post by:
Hello, code like os.system(command) only works for some values of 'command' on my system (Linux). A certain shell command (that *does* run on the command line) does not work when called...
18
by: jrefactors | last post by:
If the C programs have UNIX system calls such as fork(), alarm(), etc.., we should call it UNIX programs, not traditional C programs? We couldn't compile the programs with system calls using VC++...
10
by: Niall | last post by:
I'm not quite sure which groups to post this to, so short of a massive crosspost, I decided on these two. I am running into troubles with resource usage of our app on Win2k and above systems. In...
2
by: Phill | last post by:
I've got a text based system currently opperating via telnet sessions that I'm thinking of doing graphically w/.Net but am not sure If I can reproduce the same benefits in Windows. Basically it...
9
by: Xah Lee | last post by:
REQUIREMENTS FOR A VISUALIZATION SOFTWARE SYSTEM FOR 2010 Xah Lee, 2007-03-16 In this essay, i give a list of requirements that i think is necessary for a software system for creating...
21
by: omkar pangarkar | last post by:
Hi all, I have two simple hello world programs one using printf() and other using write() --prog 1-- #include<stdio.h> #include<stdlib.h> int main() { printf("Hello"); /* up to here...
4
by: Philipp.Weissenbacher | last post by:
Hi all! I wrote the following as a test case for a menu based programme: #include <iostream> #include <cstring> using namespace std; #define cls system("cls") const int SIZE = 10;
3
by: R. Bernstein | last post by:
The next release of pydb will have the ability to go into ipython from inside the debugger. Sort of like how in ruby-debug you can go into irb :-) For ipython, this can be done pretty simply;...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.