タグ

関連タグで絞り込む (2)

タグの絞り込みを解除

C・C++に関するamerica66のブックマーク (1)

  • C言語 - プロセスの生成

    宣言:pid_t waitpid(pid_t pid, int *status, int options); #include <stdio.h> #include <sys/types.h> #include <unistd.h> #include <stdlib.h> #include <sys/wait.h> int main(int argc, char** argv) { pid_t pid; int status; /// 新しいプロセスを作る /// カーネルは、同じプロセスをもう1つ作る pid = fork(); /// プロセス作成に失敗した時は、0未満を返す if ( pid < 0 ) { fprintf (stderr, "fork error\n"); exit(1); } /// 子プロセスのpidは、0 if (pid == 0) { execl("/bin

  • 1