本文整理汇总了C++中TError::GetError方法的典型用法代码示例。如果您正苦于以下问题:C++ TError::GetError方法的具体用法?C++ TError::GetError怎么用?C++ TError::GetError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TError
的用法示例。
在下文中一共展示了TError::GetError方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PrintError
void ICmd::PrintError(const TError &error, const string &str) {
if (error.GetMsg().length())
std::cerr << str << ": " << ErrorName(error.GetError()) << " (" << error.GetMsg() << ")" << std::endl;
else
std::cerr << str << ": " << ErrorName(error.GetError()) << std::endl;
}
示例2: Start
TError TTask::Start() {
int ret;
int pfd[2], syncfd[2];
Pid = 0;
if (Env->CreateCwd) {
TError error = CreateCwd();
if (error) {
if (error.GetError() != EError::NoSpace)
L_ERR() << "Can't create temporary cwd: " << error << std::endl;
return error;
}
}
ExitStatus = 0;
ret = pipe2(pfd, O_CLOEXEC);
if (ret) {
TError error(EError::Unknown, errno, "pipe2(pdf)");
L_ERR() << "Can't create communication pipe for child: " << error << std::endl;
return error;
}
Rfd = pfd[0];
Wfd = pfd[1];
// we want our child to have portod master as parent, so we
// are doing double fork here (fork + clone);
// we also need to know child pid so we are using pipe to send it back
pid_t forkPid = fork();
if (forkPid < 0) {
TError error(EError::Unknown, errno, "fork()");
L() << "Can't spawn child: " << error << std::endl;
close(Rfd);
close(Wfd);
return error;
} else if (forkPid == 0) {
TError error;
SetDieOnParentExit(SIGKILL);
SetProcessName("portod-spawn-p");
char stack[8192];
(void)setsid();
// move to target cgroups
for (auto cg : Env->LeafCgroups) {
error = cg.second->Attach(getpid());
if (error) {
L() << "Can't attach to cgroup: " << error << std::endl;
ReportPid(-1);
Abort(error);
}
}
error = Env->ClientMntNs.SetNs();
if (error) {
L() << "Can't move task to client mount namespace: " << error << std::endl;
ReportPid(-1);
Abort(error);
}
error = ReopenStdio();
if (error) {
ReportPid(-1);
Abort(error);
}
error = Env->ParentNs.Enter();
if (error) {
L() << "Cannot enter namespaces: " << error << std::endl;
ReportPid(-1);
Abort(error);
}
int cloneFlags = SIGCHLD;
if (Env->Isolate)
cloneFlags |= CLONE_NEWPID | CLONE_NEWIPC;
if (Env->NewMountNs)
cloneFlags |= CLONE_NEWNS;
if (!Env->Hostname.empty())
cloneFlags |= CLONE_NEWUTS;
if (Env->NetCfg.NewNetNs)
cloneFlags |= CLONE_NEWNET;
int ret = pipe2(syncfd, O_CLOEXEC);
if (ret) {
TError error(EError::Unknown, errno, "pipe2(pdf)");
L() << "Can't create sync pipe for child: " << error << std::endl;
ReportPid(-1);
Abort(error);
}
WaitParentRfd = syncfd[0];
//.........这里部分代码省略.........