- 創建clients個進程
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <stdlib.h>
int clients = 3;
int main(int argc, char *argv[])
{
int i;
pid_t pid;
if (argc != 2)
{
fprintf(stderr, "usage: %s clients\n", argv[0]);
return 0;
}
clients = atoi(argv[1]);
for(i=0;i<clients;i++)
{
pid=fork();
if(pid <= (pid_t) 0)
{
/* child process or error*/
sleep(1); /* make childs faster */
break;
}
}
printf("hello,world\n");
exit(0);
}