close(fd[0]);

close(fd2[1]);

system(pCmd);

read(fd2[0], pResult, maxlen);

pResult[strlen(pResult)-1] = 0;

write(fd[1], pResult, strlen(pResult));

close(fd2[0]);

exit(0);

}

// parent process

close(fd[1]);

p = pResult;

left = maxlen;

while((count = read(fd[0], p, left))) {

p = count;

left -= count;

if(left == 0)

break;

}

close(fd[0]);

return 0;

}

int main(void)

{

char result[1025];

my_system(“/sbin/ifconfig”, result, 1025);

printf(“the result is\n\n%s\n”, result);

return 0;

}

责任编辑:Ct

关于嵌入式技术就介绍完了,您有什么想法可以联系小编。