Can I use system() or popen API in nacl?

303 views
Skip to first unread message

terut...@gmail.com

unread,
Aug 9, 2018, 5:49:51 PM8/9/18
to Native-Client-Discuss
Hello

I'm doing test nacl sample.
basic sample is successed
Add a source to system() or popen() api.
The code is failed.

How can I use system() api?

my code is below.

-----

#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");

    std::string bbb = strerror(errno);
    PostMessage(bbb.c_str());  
    PostMessage(errno);    

    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

terut...@gmail.com

unread,
Aug 9, 2018, 9:11:28 PM8/9/18
to Native-Client-Discuss
bbb.c_str() result "Function not implemented"
errno result 38
I use OSX.

2018년 8월 10일 금요일 오전 6시 49분 51초 UTC+9, terut...@gmail.com 님의 말:

Derek Schuff

unread,
Aug 10, 2018, 1:26:25 PM8/10/18
to native-cli...@googlegroups.com
The short answer is no. Native Client programs do not have access to underlying system calls; they have essentially the same capabilities as JS code on the web. You'll need to use the PPAPI APIs in the browser.

--
You received this message because you are subscribed to the Google Groups "Native-Client-Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to native-client-di...@googlegroups.com.
To post to this group, send email to native-cli...@googlegroups.com.
Visit this group at https://groups.google.com/group/native-client-discuss.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages