diff options
Diffstat (limited to 'util')
-rw-r--r-- | util/fbrun/FbRun.cc | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/util/fbrun/FbRun.cc b/util/fbrun/FbRun.cc index 2843cff..1dd813a 100644 --- a/util/fbrun/FbRun.cc +++ b/util/fbrun/FbRun.cc | |||
@@ -47,6 +47,10 @@ | |||
47 | #include <fstream> | 47 | #include <fstream> |
48 | #include <algorithm> | 48 | #include <algorithm> |
49 | 49 | ||
50 | #ifdef _WIN32 | ||
51 | #include <cstring> | ||
52 | #endif | ||
53 | |||
50 | using std::cerr; | 54 | using std::cerr; |
51 | using std::endl; | 55 | using std::endl; |
52 | using std::string; | 56 | using std::string; |
@@ -122,6 +126,7 @@ void FbRun::run(const std::string &command) { | |||
122 | return; | 126 | return; |
123 | } | 127 | } |
124 | 128 | ||
129 | #ifdef HAVE_FORK | ||
125 | // fork and execute program | 130 | // fork and execute program |
126 | if (!fork()) { | 131 | if (!fork()) { |
127 | 132 | ||
@@ -133,6 +138,26 @@ void FbRun::run(const std::string &command) { | |||
133 | execl(shell, shell, "-c", command.c_str(), static_cast<void*>(NULL)); | 138 | execl(shell, shell, "-c", command.c_str(), static_cast<void*>(NULL)); |
134 | exit(0); //exit child | 139 | exit(0); //exit child |
135 | } | 140 | } |
141 | #elif defined(_WIN32) | ||
142 | /// @todo - unduplicate from FbCommands.cc | ||
143 | #ifndef PATH_MAX | ||
144 | #define PATH_MAX 1024 | ||
145 | #endif | ||
146 | char comspec[PATH_MAX] = {0}; | ||
147 | char * env_var = getenv("COMSPEC"); | ||
148 | if (env_var != NULL) { | ||
149 | strncpy(comspec, env_var, PATH_MAX - 1); | ||
150 | comspec[PATH_MAX - 1] = '\0'; | ||
151 | } else { | ||
152 | strncpy(comspec, "cmd.exe", 7); | ||
153 | comspec[7] = '\0'; | ||
154 | } | ||
155 | |||
156 | spawnlp(P_NOWAIT, comspec, comspec, "/c", command.c_str(), static_cast<void*>(NULL)); | ||
157 | |||
158 | #else | ||
159 | #error "Can't build FbRun - don't know how to launch without fork on your platform" | ||
160 | #endif | ||
136 | 161 | ||
137 | hide(); // hide gui | 162 | hide(); // hide gui |
138 | 163 | ||