摘要: /* * simple fork usage */ #include <unistd.h> #include <stdio.h> #include <stdlib.h> int main() { pid_t child; if ((child = fork()) == -1) { perror("fork"); exit(EXIT_FAILURE); } else if(child == 0) { puts("in child"); printf ("\tchild pid = %d\n", get 阅读全文
posted @ 2012-10-26 18:42 CodingMonkey 阅读(182) 评论(0) 推荐(0) 编辑
摘要: system函数声明为: int system(const char *string); string为你要输入的命令。 实例如下: /* * Demonstrate the system() call */ #include <stdio.h> #include <stdlib.h> int main() { int retval;//retval is the return value of the system call retval = system("ls -l"); if(retval == 127) { fprintf(stderr, 阅读全文
posted @ 2012-10-26 17:38 CodingMonkey 阅读(179) 评论(0) 推荐(0) 编辑