一个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); } }