我的程序取自user.then範圍,然後創建3個進程並逐個執行它們 但我希望所有進程同時運行。執行進程一致
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/wait.h>
void function();
cin>>range;
cin>>process;
int main() {
int range = 1000;
int i;
int pid;
int pid1;
for(i = 0; i < ; i++) {
pid1 = fork();
}
if(pid1==0) {
pid = getpid();
printf("The process id is: %d\n", pid);
function(range);
}
else {
wait(0);
}
return 0;
}
你能不能做出三個不同的線程和叉子? –
你想要3個過程?還是8? – Beta
如果你等待(NULL)你正在開發一個接一個的進程 – Alexis