aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/FbCommands.cc22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/FbCommands.cc b/src/FbCommands.cc
index be52e47..63aa79d 100644
--- a/src/FbCommands.cc
+++ b/src/FbCommands.cc
@@ -113,15 +113,26 @@ ExecuteCmd::ExecuteCmd(const string &cmd, int screen_num):m_cmd(cmd), m_screen_n
113} 113}
114 114
115void ExecuteCmd::execute() { 115void ExecuteCmd::execute() {
116#ifndef __EMX__
117 run(); 116 run();
118#else // __EMX__
119 spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", m_cmd.c_str(), static_cast<void*>(NULL));
120#endif // !__EMX__
121
122} 117}
123 118
124int ExecuteCmd::run() { 119int ExecuteCmd::run() {
120#if defined(__EMX__) || defined(_WIN32)
121#ifndef PATH_MAX
122#define PATH_MAX 1024
123#endif
124 char comspec[PATH_MAX] = {0};
125 char * env_var = getenv("COMSPEC");
126 if (env_var != NULL) {
127 strncpy(comspec, env_var, PATH_MAX - 1);
128 comspec[PATH_MAX - 1] = '\0';
129 } else {
130 strncpy(comspec, "cmd.exe", 7);
131 comspec[7] = '\0';
132 }
133
134 return spawnlp(P_NOWAIT, comspec, comspec, "/c", m_cmd.c_str(), static_cast<void*>(NULL));
135#else
125 pid_t pid = fork(); 136 pid_t pid = fork();
126 if (pid) 137 if (pid)
127 return pid; 138 return pid;
@@ -161,6 +172,7 @@ int ExecuteCmd::run() {
161 exit(EXIT_SUCCESS); 172 exit(EXIT_SUCCESS);
162 173
163 return pid; // compiler happy -> we are happy ;) 174 return pid; // compiler happy -> we are happy ;)
175#endif
164} 176}
165 177
166FbTk::Command<void> *ExportCmd::parse(const string &command, const string &args, 178FbTk::Command<void> *ExportCmd::parse(const string &command, const string &args,