diff options
author | Ryan Pavlik <rpavlik@iastate.edu> | 2011-10-28 19:07:49 (GMT) |
---|---|---|
committer | Ryan Pavlik <rpavlik@iastate.edu> | 2011-10-31 15:54:09 (GMT) |
commit | 3ca61475fb14e8c082a9d277f0e433d9cb4af9a0 (patch) | |
tree | 1831977ee12e3ed89ed1043950b6d67264b69f65 | |
parent | b82999c1ac47b7b559815636f615d0c1ffa5cb56 (diff) | |
download | fluxbox_paul-3ca61475fb14e8c082a9d277f0e433d9cb4af9a0.zip fluxbox_paul-3ca61475fb14e8c082a9d277f0e433d9cb4af9a0.tar.bz2 |
FbRun.cc: Fix on windows where there is no fork
-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 | ||