Files
Linux-C-Notes/C13-Linux系统编程/process_basic/sleep.c
2024-05-14 07:39:34 +08:00

45 lines
701 B
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
/**
* @brief few: folk, execl, wait
* @details
*
* @param argc
* @param argv
* @return int
*/
int main(int argc, char **argv)
{
pid_t pid;
puts("Begin!");
fflush(NULL);
pid = fork();
if (pid < 0)
{
perror("fork()");
exit(1);
}
if (0 == pid) // child
{
// execl("/bin/sleep", "sleep", "100", NULL);
execl("/bin/sleep", "httpd", "100", NULL);
// ! 低级木马进程树里看到的是httpd 100
perror("execl()");
exit(1);
}
wait(NULL);
puts("End!");
exit(0);
}