Вот что я делаю:
Код: Выделить всё
pid_t LaunchNewConsole( const std::string& cmd, const std::string& title ) {
const char* term_exe = "xterm";
std::vector args;
args.push_back(term_exe);
args.push_back("-title");
args.push_back(title);
args.push_back("-e");
args.push_back("/bin/sh");
args.push_back("-c");
args.push_back("exec " + cmd);
std::vector argv_c;
for (const std::string& s : args) {
argv_c.push_back(s.c_str());
}
argv_c.push_back(nullptr);
pid_t pid = -1;
int ret = posix_spawnp(
&pid,
term_exe,
nullptr,
nullptr,
const_cast(argv_c.data()),
environ
);
if (ret!= 0) {
throw std::system_error(ret, std::system_category(), "posix_spawnp failed for xterm");
}
return pid;
}
Случайное количество процессов повреждено, что приводит к ошибке «malloc()». Кажется, память некоторых переменных распределена неправильно.
Подробнее здесь: https://stackoverflow.com/questions/798 ... s-on-linux
Мобильная версия