有关spawn用法 謝謝

(Sth wrong about my chinese fonts, use my poor english)

The following is a small part in my code:

.
.
.
szArguments={clienttest,NULL};
int iReceiveIdentifier;
pid_t pidClientIdentifier;
struct inheritance inInheritance;
.
.
.
.
// Execute the client program
if((pidClientIdentifier = spawn("/root/workspace/clienttest/x86/o/clienttest", 0, NULL, &inInheritance, szArguments, NULL)) == -1)

printf("[Server] Failed to launch client\n");

else
printf("[Server] Client created with PID = %d\n", pidClientIdentifier);


I have already used the IDE to compile the clienttest.c and stored it in the above directory, actually in both command line window and IDE, I also have tested the exuatable “clienttest” and it could work.

but no matter how hard I try, I cant launch it in the servertest and the console always shows the information “fail to lanch clienttest”. Xtang etc experts, kindly explain it for me and give me a help.

THx again!!!

  1. It is always a good idea to print out “errno” or “strerrno(errno)” when you have an error. That will tell you why the function failed.

printf("[Server] Failed to launch client. (%s)\n", strerror(errno));

  1. try to memset the inherit before calling spawn().

memset(&inInheritance, 0, sizeof(inInheritance));

谢谢xtang先生的指点 问题果然迎刃而解。

问题好像就出在您提到的第二点上。 将printf改成如1的形式后,看到的信息是:
fail to launch the client not supported
加上了memset语句之后 便可以正常运行了。还发现的一点是: path name好像不用写全neutrino也是可以认的。
不过能请您给解释一下这是为什么呢? 也就是是说memset在这个程序里的作用是什么呢?

另外我记得您在一片帖子里提到调试时用命令行也很方便, 现在有些体会了 突出的一点是命令行调试,结果可以很清晰的显示出来,比如client 和server的信息的交替显示是实时的,而用ide看到是很奇怪的顺序 您在这方面有什么建议吗? 还有IDE的console显示是不是真的不是很理想还是我有什么地方疏忽了?
再次谢谢您和大家的多次帮助

inherit如果不清零,里面的内容无法保证,会被库函数认为非法。SPAWN的FLAG里面有一条就是搜索路径。