p_create失败:资源暂时不可用

时间:2017-06-22 04:30:06

标签: c++ linux multithreading pthreads posix

我正在尝试创建多个RequestChannels(管道)

我在这里制作主要频道:

pid_t controlPID;
cout << "CLIENT STARTED:" << endl;

controlPID = fork();
if(controlPID == 0 ){
    execl("./dataserver", (char*) NULL);
}
else{
cout << "Establishing control channel... " << flush;
RequestChannel chan("control", RequestChannel::CLIENT_SIDE);
cout << "done." << endl;
}

这里我制作了几个频道:( w = 10或用户输入)

RequestChannel* channels[w];
    for(int i = 0; i < w; i++){
        string reply = chan.send_request("newthread");
        channels[i] = new RequestChannel(reply, RequestChannel::CLIENT_SIDE);
        channels[i]->cwrite("hello"); //write the request hello in request channel buffer.
    }

起初它已经工作了好几次,但逐渐建立了一些渠道而其他渠道...... ...

Reading next request from channel (control) ... done (control).
New request is newthread
p_create failed: Resource temporarily unavailable

最终没有制作线程。 发生了什么?我怎样才能解决这个问题? 我期待着你的帮助。

0 个答案:

没有答案