一個C++多進程的例子
#include <iostream>
#include <unistd.h>
int main(int argc, char *argv[]) {
pid_t pid = fork();
if (pid > 0) {
std::cout << "In parent process." << std::endl;
}
if (pid == 0) {
std::cout << "In child process." << std::endl;
execlp("echo", "", "Hello world!", NULL);
}
}

浙公網(wǎng)安備 33010602011771號