如果我用execl删除行,则fwrite将再次开始工作。可能是什么问题?
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/wait.h>
int main()
{
FILE *fptr;
fptr = fopen("./belenkas", "w+");
fwrite("echo $(whoami)", 1, sizeof("echo $(whoami)"), fptr);
execl("/bin/sh" ,"sh" , "./belenkas", NULL);
}
fclose(fptr)
解决了。谢谢。