ChinaUnix.net
相关文章推荐:

execlp 参数要求

小弟正在看execlp的函数,写了一段代码,其中几行如下: ...... char *fname="$HOME/tmp/ttmp.txt"; ...... execlp( "cat", "cat", fname, 0 ); ...... exit( 0 ); 在$HOME/tmp目录下确有ttmp.txt文件,且我用system调用也可成功,编译正 常, 生成可执行程序后,运行报: cat: cannot open fname: No such file or directory (error 2). 请问众位老大,在execlp中能不能传char *, 还有输出重定向符参数怎...

by ylbaby2003 - C/C++ - 2004-10-25 16:46:49 阅读(3657) 回复(6)

相关讨论

大家好/ 关于execlp()用法网上都是以调用ls为例子的,如果想在子进程中实现自己定一的函数那? 程序如下 if(proFlag==0) { printf("in child\n"); execlp("Max","Max","444","22",(char *)0); perror("execlp"); } else { sleep(5); wait(&n); printf("IN parent:"); printf("%d",n); } 结果之显示了in child,后面没显示,也没有错误信息,查看进程列表有个max的僵尸进程,如果将max改为系统ls命令就能实现列目录功能...

by computerzanz - C/C++ - 2009-05-17 16:56:50 阅读(1761) 回复(7)

exec系列函数中 int execlp(const char *filename,char *const arg0,...(char *)0 ) arg0参数起什么作用 实际程序中 execlp("iptables","","-t","nat","-L",NULL) 和execlp("iptables","iptables","-t","nat","-L",NULL)的效果是一样的

by kingld - C/C++ - 2003-12-20 11:43:50 阅读(718) 回复(2)

请问: 1. 当发布一个execlp调用时,系统用什么值去生成一个系统进程表项? 2. 是否可以通过file argv引用此表项? 谢谢。

by cores - C/C++ - 2009-11-02 09:38:50 阅读(925) 回复(1)

#include #include #include #define Ports 3306 main() { struct sockaddr_in server; int socked,port; server.sin_family=AF_INET; server.sin_addr.s_addr=htonl(INADDR_ANY); server.sin_port = htons((short)Ports); socked=socket(AF_INET,SOCK_STREAM,0); port=bind(socked,(struct sockaddr *)&server,sizeof(server)); if (port==0) { execlp("mysql.server","m...

by 修理工 - C/C++ - 2007-12-15 09:33:52 阅读(1293) 回复(0)

#include #include #include #define Ports 3306 main() { struct sockaddr_in server; int socked,port; server.sin_family=AF_INET; server.sin_addr.s_addr=htonl(INADDR_ANY); server.sin_port = htons((short)Ports); socked=socket(AF_INET,SOCK_STREAM,0); port=bind(socked,(struct sockaddr *)&server,sizeof(server)); if (port==0) { execlp("mysql.server","m...

by 修理工 - C/C++ - 2007-12-14 01:47:10 阅读(1060) 回复(1)

#include #include #include #include int main(void) { pid_t childpid; childpid = fork(); if (childpid == -1) { perror("Failed to fork"); return 1; } if (childpid == 0) { /* child code */ execl("/bin/cat","/bin/cat","/etc/passwd","|","more", NULL); perror("Child failed to exec ls");...

by linuxcici - C/C++ - 2006-03-15 19:51:23 阅读(951) 回复(7)

在程序中调用execlp("/root/a","a","/b.bin",(char *)0);当这个函数执行完毕了如何让它再次执行?请赐教!谢谢!

by yueying - C/C++ - 2007-01-06 16:42:03 阅读(808) 回复(3)

#include #include #include #include #include #include #include #define MAXLINE 50 int main(void) { char buf[MAXLINE]; pid_t pid; int status,i; // char lsargv[] ={“ls”,”-l”, 0}; // char lsenvp[] ={“PATH=/bin:/usr/bin”, 0}; printf("Now it is before fork ...

by declare - C/C++ - 2006-07-19 10:01:08 阅读(943) 回复(4)

我用fork创建一个子进程,子进程用execlp()执行一个外部程序. 我的问题是:这个外部程序的父进程是调用 fork()的那个进程,还是init进程?

by xltao - C/C++ - 2005-12-23 10:54:23 阅读(3285) 回复(9)

在linux 进程程序中这样写道: while(proFlag=fork()); if(proFlag==0) switch(funFlag) { case 1:execlp("max",agv[0],agv[1],(char *)0);//max 是同目录下的一个可执行函数 case 2:printf("*******");break; default: } 编译运行,程序能保证funFlag==1,但结果打印****** 问题0:用execlp()不用添加当前max()所在路径的环境变量吗? 问题1:不是说execlp会将父进程中的代码断覆盖成自己的么?怎么还会执行后面的代码?...

by computerzanz - C/C++ - 2009-05-14 22:13:03 阅读(2716) 回复(9)