サンプルを作ってみました。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#define PARA 4
static void child(void)
{
char buf[1024];
while (fgets(buf, sizeof buf, stdin) != NULL) {
char cmd[1024], *p;
if ((p = strchr(buf, '\n')) != NULL)
*p = '\0';
sprintf(cmd, "wget '%s'", buf);
system(cmd);
}
}
int main(void)
{
int i;
int fd[PARA];
for (i = 0; i < PARA; i++) {
int fds[2];
if (pipe(fds) == -1) {
perror("pipe");
exit(1);
}
switch (fork()) {
case -1:
/* エラー */
perror("fork");
exit(1);
case 0:
/* 子プロセス */
close(fds[1]);
dup2(fds[0], 0);
child();
exit(0);
default:
/* 親プロセス */
close(fds[0]);
fd[i] = fds[1];
}
}
char buf[1024];
int to_child = 0;
while (fgets(buf, sizeof buf, stdin) != NULL) {
write(fd[to_child], buf, strlen(buf));
if (++to_child >= PARA)
to_child = 0;
}
return 0;
}
実行すると、子プロセスを4つ作り、親プロセスは子プロセスにパイプ経由で URL を送り、子プロセスはそれを受け取り、処理します。当初、子プロセス 1つにつき 1つの URL を処理して、どんどんプロセスを作ってどんどん終了して、という感じで考えていましたが、質問内容を改めて読み、一定個数のプロセスだけで処理した方が簡単なのでは、と思い直しました。
あと、このサンプルでは URL は親プロセスが標準入力からもらいます。ダウンロードは私が wget の方が慣れているため wget を使いました。