我正在测试nacl样品。
我的OSX基本样本成功了。
将源添加到system()或popen()函数。
代码失败。
system()或popen()返回值为-1,strerror(errno)值为“功能未实现”
如何使用system()函数?
我的代码在下面。
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/var.h"
#include <errno.h>
#include <cstdio>
#include <cstdlib>
#include <iostream>
class HelloTutorialInstance : public pp::Instance {
public:
explicit HelloTutorialInstance(PP_Instance instance) : pp::Instance(instance)
{}
virtual ~HelloTutorialInstance() {}
const char* const kHelloString = "test_nacl";
const char* const kReplyString = "hello 1111";
virtual void HandleMessage(const pp::Var& var_message) {
int s = system("ls"); // s's value is -1
std::string bbb = strerror(errno);
PostMessage(bbb.c_str()); // Value is "Function not implemented"
PostMessage(errno); // Vakye us 38
PostMessage("----------");
}
};
class HelloTutorialModule : public pp::Module {
public:
HelloTutorialModule() : pp::Module() {}
virtual ~HelloTutorialModule() {}
virtual pp::Instance* CreateInstance(PP_Instance instance) {
return new HelloTutorialInstance(instance);
}
};
namespace pp {
Module* CreateModule() {
return new HelloTutorialModule();
}
} // namespace pp