开发者

Write a dispatch program in c to run other c programs in Linux

I would like to write a small program that will run other programs. I'm not just trying to get their output as stdio for the current process, but rather want to simply use the program to use as a dispatch program.

I don't want to compile them together, but rather keep all th开发者_开发百科e different programs separate.

I'm assuming that using a shell script would be the normal way of doing this, but I specifically want to know how it would be done in C on Linux.


You could do something like fork and use execve.

I'm not entirely understanding the problem though. Do you need the dispatcher to be able to read the output of the dispatched program?


You can use the system() API to call these other programs. What system() does is actually forks a shell and runs the program in that shell. You can specify arguments to these external programs and even check their return status. "man system" is your friend

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜