make the execute process better
This commit is contained in:
parent
ca31686579
commit
d7bf31c5b5
1 changed files with 2 additions and 10 deletions
|
@ -455,21 +455,13 @@ void screen::updateActiveWindow() {
|
||||||
void screen::execCommand(const string &cmd) const {
|
void screen::execCommand(const string &cmd) const {
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
if ((pid = fork()) == 0) {
|
if ((pid = fork()) == 0) {
|
||||||
extern char **environ;
|
|
||||||
|
|
||||||
char *const argv[] = {
|
|
||||||
"sh",
|
|
||||||
"-c",
|
|
||||||
const_cast<char *>(cmd.c_str()),
|
|
||||||
0
|
|
||||||
};
|
|
||||||
// make the command run on the correct screen
|
// make the command run on the correct screen
|
||||||
if (putenv(const_cast<char*>(_info->displayString().c_str()))) {
|
if (putenv(const_cast<char*>(_info->displayString().c_str()))) {
|
||||||
cout << "warning: couldn't set environment variable 'DISPLAY'\n";
|
cout << "warning: couldn't set environment variable 'DISPLAY'\n";
|
||||||
perror("putenv()");
|
perror("putenv()");
|
||||||
}
|
}
|
||||||
execve("/bin/sh", argv, environ);
|
execl("/bin/sh", "sh", "-c", cmd.c_str(), NULL);
|
||||||
exit(127);
|
exit(-1);
|
||||||
} else if (pid == -1) {
|
} else if (pid == -1) {
|
||||||
cout << _epist->getApplicationName() <<
|
cout << _epist->getApplicationName() <<
|
||||||
": Could not fork a process for executing a command\n";
|
": Could not fork a process for executing a command\n";
|
||||||
|
|
Loading…
Reference in a new issue