all repos — fluxbox @ d4f682c7bd1ca150693fa3028d0a8c6bdd1820fd

custom fork of the fluxbox windowmanager

FbCommands.cc: Implement ExecuteCmd for Windows
Ryan Pavlik rpavlik@iastate.edu
commit

d4f682c7bd1ca150693fa3028d0a8c6bdd1820fd

parent

4ded38f43f2411210ab9508d8d8ac83270d6e5d2

1 files changed, 17 insertions(+), 5 deletions(-)

jump to
M src/FbCommands.ccsrc/FbCommands.cc

@@ -113,15 +113,26 @@

} void ExecuteCmd::execute() { -#ifndef __EMX__ run(); -#else // __EMX__ - spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", m_cmd.c_str(), static_cast<void*>(NULL)); -#endif // !__EMX__ - } int ExecuteCmd::run() { +#if defined(__EMX__) || defined(_WIN32) +#ifndef PATH_MAX +#define PATH_MAX 1024 +#endif + char comspec[PATH_MAX] = {0}; + char * env_var = getenv("COMSPEC"); + if (env_var != NULL) { + strncpy(comspec, env_var, PATH_MAX - 1); + comspec[PATH_MAX - 1] = '\0'; + } else { + strncpy(comspec, "cmd.exe", 7); + comspec[7] = '\0'; + } + + return spawnlp(P_NOWAIT, comspec, comspec, "/c", m_cmd.c_str(), static_cast<void*>(NULL)); +#else pid_t pid = fork(); if (pid) return pid;

@@ -161,6 +172,7 @@ execl(shell, shell, "-c", m_cmd.c_str(), static_cast<void*>(NULL));

exit(EXIT_SUCCESS); return pid; // compiler happy -> we are happy ;) +#endif } FbTk::Command<void> *ExportCmd::parse(const string &command, const string &args,