📜  linux sleep with exec bin sleep - C 编程语言代码示例

📅  最后修改于: 2022-03-11 15:04:33.940000             🧑  作者: Mango

代码示例2
int pid= fork();
if (pid==0) { // child
    execl("/bin/sleep", "sleep", argv[1], NULL); // argv[1] is the sleeptime
    perror("execl");
    return EXIT_FAILURE;
}
if (waitpid(pid,NULL,0)<0) {
    perror("waitpid");
    return EXIT_FAILURE;
}