Say i have an exe, lets say sum.exe. Now say the code for sum.exe is
void main ()
{
int a,b;
scanf (\"%d%d\", &a, &b);
printf (\"%d\", a+b);
}
>
In C on platforms whose name end with X (i.e. not Windows), the key components are:
pipe
- Returns a pair of file descriptors, so that what's written to one can be read from the other.
fork
- Forks the process to two, both keep running the same code.
dup2
- Renumbers file descriptors. With this, you can take one end of a pipe and turn it into stdin or stdout.
exec
- Stop running the current program, start running another, in the same process.
Combine them all, and you can get what you asked for.