C/C++の宿題を片付けます 103代目 at TECH
[2ch|▼Menu]
680:デフォルトの名無しさん
08/01/27 21:55:48
>>676
showpidがおかしくないか?

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>

int main() {
pid_t pid;
int i, status, flg = 0;
for (i = 0; i < 10; ++i) {
if ((pid = fork()) < 0) {
fprintf(stderr, "error\n");
exit(1);
}

if (pid == 0) {
execv("showpid", NULL);
exit(1);
} else {
if (flg == 0) {
flg = 1;
printf("I am a parent with pid = %d.My child is %d.\n",getpid(),pid);
}
waitpid(pid, &status, 0);
}
}

return 0;
}


次ページ
続きを表示
1を表示
最新レス表示
スレッドの検索
類似スレ一覧
話題のニュース
おまかせリスト
▼オプションを表示
暇つぶし2ch

4962日前に更新/357 KB
担当:undef