Browse Source

Gave up on being able to call more complex commands. Should work without crashes now.

merge-requests/365/head
eidheim 10 years ago
parent
commit
7be6c3e91d
  1. 1
      src/notebook.cc
  2. 9
      src/terminal.cc

1
src/notebook.cc

@ -120,6 +120,7 @@ bool Notebook::save(int page) {
Singleton::terminal()->print("File saved to: " +view->file_path+"\n");
//If CMakeLists.txt have been modified:
//TODO: recreate cmake even without directories open?
if(boost::filesystem::path(view->file_path).filename().string()=="CMakeLists.txt") {
if(directories.cmake && directories.cmake->project_path!="" && boost::filesystem::path(view->file_path)>=directories.cmake->project_path && CMake::create_compile_commands(directories.cmake->project_path.string())) {
directories.open_folder();

9
src/terminal.cc

@ -57,6 +57,7 @@ pid_t popen3(const char *command, int *input_descriptor, int *output_descriptor,
close(p_stderr[0]);
dup2(p_stderr[1], 2);
//setpgid(0, 0); //TODO: get this working so we can execute without calling exec from sh -c (in that way we can call more complex commands)
execl("/bin/sh", "sh", "-c", command, NULL);
perror("execl");
exit(1);
@ -240,15 +241,19 @@ void Terminal::async_execute(const std::string &command, const std::string &path
void Terminal::kill_executing() {
async_and_sync_execute_mutex.lock();
int status;
for(auto &pid: async_execute_descriptors) {
kill(pid.first, SIGTERM); //signal_execl_exit is not always called after kill! Hence the following lines:
close(async_execute_descriptors.at(pid.first)[0]);
close(async_execute_descriptors.at(pid.first)[1]);
close(async_execute_descriptors.at(pid.first)[2]);
int status;
kill(pid.first, SIGTERM); //signal_execl_exit is not always called after kill!
while(waitpid(pid.first, &status, WNOHANG) > 0) {}
async_execute_status[pid.first]=status;
}
/*for(auto &pid: async_execute_descriptors) {
kill(-pid.first, SIGTERM);
while(waitpid(-pid.first, &status, WNOHANG) > 0) {}
}*/
async_and_sync_execute_mutex.unlock();
}

Loading…
Cancel
Save