I\'ve been curious how rem
in Linux works and trying to write my own C
code that can delete a file but when I searched for the answer, I only got t
#include
#include
#include
#include
#include
int main(){
int status;
pid_t pid = fork();
if(-1 == pid){
printf("fork() failed");
exit(EXIT_FAILURE);
}else if(pid == 0){
execl("/bin/sh", "sh", "-c", "rm /tmp/san.txt", (char *) NULL);
}else{
printf("[%d]fork with id %d\n",pid);
waitpid(pid,&status,0);
}
return 0;
}