aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathias <mathias>2007-06-06 06:22:37 (GMT)
committermathias <mathias>2007-06-06 06:22:37 (GMT)
commitdff2aa33561b00e97b3561892fb690ba9f2968c6 (patch)
treee1cde447e834f5fe2cb7bbc3fd3fbd4f78c35de7
parent467cb9ac6d951bbd37cb809370fa2e5b27f7e032 (diff)
downloadfluxbox-dff2aa33561b00e97b3561892fb690ba9f2968c6.zip
fluxbox-dff2aa33561b00e97b3561892fb690ba9f2968c6.tar.bz2
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>
-rw-r--r--ChangeLog3
-rw-r--r--src/FbCommands.cc5
-rw-r--r--util/fbrun/FbRun.cc9
3 files changed, 15 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 8c67f62..07a09d7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
1 (Format: Year/Month/Day) 1 (Format: Year/Month/Day)
2Changes for 1.0.0: 2Changes for 1.0.0:
3*07/06/06:
4 * Fix to avoid rogue instances of /bin/sh after forking away programs (Mathias)
5 util/fbrun/FbRun.cc src/FbCommands.cc
3*07/06/04: 6*07/06/04:
4 * Fix fluxbox.1.in, and asciidoc, menu command is "wallpapers" not 7 * Fix fluxbox.1.in, and asciidoc, menu command is "wallpapers" not
5 "wallpaper". asciidoc manpages are stale. 8 "wallpaper". asciidoc manpages are stale.
diff --git a/src/FbCommands.cc b/src/FbCommands.cc
index afa7984..4247820 100644
--- a/src/FbCommands.cc
+++ b/src/FbCommands.cc
@@ -154,9 +154,12 @@ int ExecuteCmd::run() {
154 // remove last number of display and add screen num 154 // remove last number of display and add screen num
155 displaystring.erase(displaystring.size()-1); 155 displaystring.erase(displaystring.size()-1);
156 displaystring += intbuff; 156 displaystring += intbuff;
157
158 std::string exec_cmd = "exec " + m_cmd;
159
157 setsid(); 160 setsid();
158 putenv(const_cast<char *>(displaystring.c_str())); 161 putenv(const_cast<char *>(displaystring.c_str()));
159 execl(shell, shell, "-c", m_cmd.c_str(), static_cast<void*>(NULL)); 162 execl(shell, shell, "-c", exec_cmd.c_str(), static_cast<void*>(NULL));
160 exit(0); 163 exit(0);
161 164
162 return pid; // compiler happy -> we are happy ;) 165 return pid; // compiler happy -> we are happy ;)
diff --git a/util/fbrun/FbRun.cc b/util/fbrun/FbRun.cc
index 7797f76..95cb94d 100644
--- a/util/fbrun/FbRun.cc
+++ b/util/fbrun/FbRun.cc
@@ -119,8 +119,15 @@ void FbRun::run(const std::string &command) {
119 119
120 // fork and execute program 120 // fork and execute program
121 if (!fork()) { 121 if (!fork()) {
122
123 char *shell = getenv("SHELL");
124 if (!shell)
125 shell = "/bin/sh";
126
127 std::string exec_cmd = "exec " + command;
128
122 setsid(); 129 setsid();
123 execl("/bin/sh", "/bin/sh", "-c", command.c_str(), static_cast<void*>(NULL)); 130 execl(shell, shell, "-c", exec_cmd.c_str(), static_cast<void*>(NULL));
124 exit(0); //exit child 131 exit(0); //exit child
125 } 132 }
126 133