-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shell processes left in the background #135
Comments
In the meantime, here's a quick POSIX sh script that does such a fix externally, allowing you to quickly test the impact such a change would have.
|
This is a interesting problem. J4dd executes the programs with I think this is why no one (including me) has discovered this issue. I've incorporated a fix into my PR #132. I would recommend you to compile and use the PR's version of j4dd because it contains many fixes and new features. If don't want to use my version of j4dd you can apply this patch to j4dd: --- a/src/Main.hh
+++ b/src/Main.hh
@@ -260,7 +260,9 @@ private:
}
this->dmenu->display();
- std::string command = get_command();
+ std::string command;
+ bool iscustom;
+ std::tie(command, iscustom) = get_command();
if (this->wrapper.length())
command = this->wrapper+" \""+command+"\"";
delete this->dmenu;
@@ -273,6 +275,8 @@ private:
static const char *shell = 0;
if((shell = getenv("SHELL")) == 0)
shell = "/bin/sh";
+ if (!iscustom)
+ command = "exec " + command;
fprintf(stderr, "%s -c '%s'\n", shell, command.c_str());
@@ -317,7 +321,7 @@ private:
return 0;
}
- std::string get_command() {
+ std::pair<std::string, bool> get_command() {
std::string choice;
std::string args;
Application *app;
@@ -326,13 +330,13 @@ private:
choice = dmenu->read_choice(); // Blocks
if(choice.empty())
- return "";
+ return std::make_pair("", false);
fprintf(stderr, "User input is: %s %s\n", choice.c_str(), args.c_str());
std::tie(app, args) = apps.search(choice, exclude_generic);
if (!app) {
- return args;
+ return std::make_pair(args, true);
}
if(usage_log) {
@@ -346,7 +350,7 @@ private:
}
ApplicationRunner app_runner(terminal, *app, args);
- return app_runner.command();
+ return std::make_pair(app_runner.command(), false);
}
private: My code (both the patch and the fdb58ae commit in #132) only prepends |
It appears that when an application is selected and a command is passed to the shell, the shell remains open until the application exits. This is of very little consequence, but is something that can be done more neatly and correctly.
I believe the change is as simple as prefixing "exec", followed by a space, to the shell command right before it is executed, causing the shell to exit while it launches the command. Right about here is where I think the change could easily be made, but embarassingly I have zero prior experience with C++ as compared to standard C and posix shell scripting.
Thanks for your time!
The text was updated successfully, but these errors were encountered: