|
Lines 142-147
int ExecuteCmd::run() {
Link Here
|
| 142 |
if (pid) |
142 |
if (pid) |
| 143 |
return pid; |
143 |
return pid; |
| 144 |
|
144 |
|
|
|
145 |
// 'displaystring' is given as 'host:number.screen'. we want to give the |
| 146 |
// new app a good home, so we remove '.screen' from what is given |
| 147 |
// us from the xserver and replace it with the screen_num of the Screen |
| 148 |
// the user currently points at with the mouse |
| 145 |
string displaystring("DISPLAY="); |
149 |
string displaystring("DISPLAY="); |
| 146 |
displaystring += DisplayString(FbTk::App::instance()->display()); |
150 |
displaystring += DisplayString(FbTk::App::instance()->display()); |
| 147 |
char intbuff[64]; |
151 |
char intbuff[64]; |
|
Lines 155-172
int ExecuteCmd::run() {
Link Here
|
| 155 |
|
159 |
|
| 156 |
sprintf(intbuff, "%d", screen_num); |
160 |
sprintf(intbuff, "%d", screen_num); |
| 157 |
|
161 |
|
|
|
162 |
// strip away the '.screen' |
| 163 |
size_t dot = displaystring.rfind(':'); |
| 164 |
dot = displaystring.find('.', dot); |
| 165 |
if (dot != string::npos) { // 'displaystring' has actually a '.screen' part |
| 166 |
displaystring.erase(dot); |
| 167 |
} |
| 168 |
displaystring += '.'; |
| 169 |
displaystring += intbuff; |
| 170 |
|
| 171 |
putenv(const_cast<char *>(displaystring.c_str())); |
| 172 |
|
| 158 |
// get shell path from the environment |
173 |
// get shell path from the environment |
| 159 |
// this process exits immediately, so we don't have to worry about memleaks |
174 |
// this process exits immediately, so we don't have to worry about memleaks |
| 160 |
const char *shell = getenv("SHELL"); |
175 |
const char *shell = getenv("SHELL"); |
| 161 |
if (!shell) |
176 |
if (!shell) |
| 162 |
shell = "/bin/sh"; |
177 |
shell = "/bin/sh"; |
| 163 |
|
178 |
|
| 164 |
// remove last number of display and add screen num |
|
|
| 165 |
displaystring.erase(displaystring.size()-1); |
| 166 |
displaystring += intbuff; |
| 167 |
|
| 168 |
setsid(); |
179 |
setsid(); |
| 169 |
putenv(const_cast<char *>(displaystring.c_str())); |
|
|
| 170 |
execl(shell, shell, "-c", m_cmd.c_str(), static_cast<void*>(NULL)); |
180 |
execl(shell, shell, "-c", m_cmd.c_str(), static_cast<void*>(NULL)); |
| 171 |
exit(EXIT_SUCCESS); |
181 |
exit(EXIT_SUCCESS); |
| 172 |
|
182 |
|
| 173 |
- |
|
|