为什么字数统计在下面的程序中输出 0 0 0?
int main(int argc, char **argv) {
pid_t pid = fork();
const char *data = "THIS IS MY DATA.";
if(pid == 0) {
// Child Process
char *tmpname = malloc(15);
strcpy(tmpname, "/tmp/datXXXXXX");
int f = mkstemp(tmpname);
//int f = open("tmpfile", O_RDWR | O_CREAT, S_IRWXU);
if(f == -1) {
perror("");
return;
}
int written = write(f, data, strlen(data));
dup2(f, STDIN_FILENO);
close(f);
char *wcargs[5] = {"wc", NULL};
execvp("wc", wcargs);
fprintf(stderr, "ERROR");
}
return 1;
}