what is the c code to execute xeyes or xclock?
which function do i use to give such linux te开发者_StackOverflow中文版rminal calls in my c program?
system
would be the correct posix call. It takes a pointer to char as the command to be executed. See man 3 system
. However system
can be completely corrupted by environment variables and an harder-to-use alternative is exec
(see here).
A little example to illustrate:
system("xeyes");
system("rm -rf $HOME"); /* never ever try this, really */
精彩评论