NDK下vfork+execl启动程序

        pid_t _pid = vfork();
        if (_pid == 0)
        {//child process
            LOGV("[ContextSharing]in child process.");
            std::string s = std::string(MODEL_DIRECTORY) + "alljoyn_sharer";
            if (0 == chmod(s.c_str(), 00777))
            {
                if (execl(s.c_str(), "execl", s.c_str(), (char *)0) == -1)
                {
                    LOGV("[ContextSharing]execl() failed! %s", strerror(errno));
                }
            }
         }

  

如果使用

execl(s.c_str(), NULL)

则会崩溃,原因未知。

 

 

posted @ 2015-07-27 10:39    阅读(567)  评论(0编辑  收藏  举报