在Linux下从一个C程序运行多个C程序

在Linux下从一个C程序运行多个C程序

问题描述:

我试图学习有关Linux下进程通信的知识,所以我写了2个相互通信的简单C程序.

I'm trying to learn a bit or 2 about process communication under Linux, so I wrote 2 simple C programs that communicate with each other.

但是,每次必须手动运行它们有点烦人,所以我想知道是否有一种方法可以制作一个可以同时运行它们的程序,就像这样:

However, it's a bit annoying to have to run them manually every single time, so I'd like to know is there a way to make a program that will run them both, something like this:

./runner program1 program2

我正在使用最新的Ubuntu和Bash shell.

I'm using latest Ubuntu and Bash shell.

run.sh脚本

#!/bin/sh
./program1 & 
./program2 &

运行命令:

$sh run.sh