sending input to a child

Guy Harris guy at auspex.UUCP
Tue Mar 14 05:22:19 AEST 1989


>I was just curious if there is a way to execute another program from
>w/in a C program.

There are a number of different ones for different operating systems. 
The only one that can be considered a part of C, rather than a part of
some particular operating system, is the "system" function, which is in
the December 7, 1988 dpANS.  However, the description of it indicates
that:

	1) not all implementations of C need *have* a "command
	   processor", and thus not all implementations of C need do
	   anything interesting with "system" except return 0 when you
	   pass it a null pointer of type "const char *" (the 0 return
	   value indicates that the implementation has no such "command
	   processor" and, therefore, that you may not be able to
	   execute any commands).

	2) the description says that the string you pass to "system" is
	   executed "in an implementation-defined manner", so you don't
	   have much in the way of guarantees about its behavior.

 
>Well, I know I can do that, but what I need to do is send input to the
>other program I exectute.

Well, there are ways to do that under UNIX, for example, but no way to
do it "in C", given the above.  There may well be ways to do it with
some particular C compiler in MS-DOS as well, and there may be ways of
doing it with other C compilers under other operating systems.

In other words, until you tell us under what operating system (and,
perhaps, with which C compiler) you intend to do this, we can't really
answer your question....



More information about the Comp.lang.c mailing list