all repos — fluxbox @ dff2aa33561b00e97b3561892fb690ba9f2968c6

custom fork of the fluxbox windowmanager

fix for the following problem:
  on *bsd /bin/sh is not just a symlink to /bin/bash as on most linux's 
  but a real standalone shell. and it behaves differently from "bash -c"
  behavior .. it doesnt exec the command given but waits till the command
  finishes. as a result a lot of "rogue" a flying around. solution is now 

     ( $SHELL or /bin/sh ) -c exec <cmd>
mathias mathias
commit

dff2aa33561b00e97b3561892fb690ba9f2968c6

parent

467cb9ac6d951bbd37cb809370fa2e5b27f7e032

3 files changed, 15 insertions(+), 2 deletions(-)

jump to
M ChangeLogChangeLog

@@ -1,5 +1,8 @@

(Format: Year/Month/Day) Changes for 1.0.0: +*07/06/06: + * Fix to avoid rogue instances of /bin/sh after forking away programs (Mathias) + util/fbrun/FbRun.cc src/FbCommands.cc *07/06/04: * Fix fluxbox.1.in, and asciidoc, menu command is "wallpapers" not "wallpaper". asciidoc manpages are stale.
M src/FbCommands.ccsrc/FbCommands.cc

@@ -154,9 +154,12 @@

// remove last number of display and add screen num displaystring.erase(displaystring.size()-1); displaystring += intbuff; + + std::string exec_cmd = "exec " + m_cmd; + setsid(); putenv(const_cast<char *>(displaystring.c_str())); - execl(shell, shell, "-c", m_cmd.c_str(), static_cast<void*>(NULL)); + execl(shell, shell, "-c", exec_cmd.c_str(), static_cast<void*>(NULL)); exit(0); return pid; // compiler happy -> we are happy ;)
M util/fbrun/FbRun.ccutil/fbrun/FbRun.cc

@@ -119,8 +119,15 @@ m_end = true; // mark end of processing

// fork and execute program if (!fork()) { + + char *shell = getenv("SHELL"); + if (!shell) + shell = "/bin/sh"; + + std::string exec_cmd = "exec " + command; + setsid(); - execl("/bin/sh", "/bin/sh", "-c", command.c_str(), static_cast<void*>(NULL)); + execl(shell, shell, "-c", exec_cmd.c_str(), static_cast<void*>(NULL)); exit(0); //exit child }