-
Notifications
You must be signed in to change notification settings - Fork 51
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
session: Become subreaper & end children upon finish #374
Conversation
I only found some time to test it quickly on my old laptop. I did the tests with FeatherPad, by launching it from lxqt-panel, pcmanfm-qt and by using keyboard shortcut (lxqt-globalkeys) and leaving its window open when logging out. In all three cases, it was terminated correctly on logout (and saved what it should have saved to its config file). Very nice! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code is good too. I'd like it to be in 0.17 if there's no objection.
089280f
to
348821a
Compare
No objection from my side (of course :) ) I just changed the sleep interval in ProceReaper thread...as there is no need to wake so often, when we use the waitcond and wake the thread instantly upon finish $ git diff
diff --git a/lxqt-session/src/procreaper.cpp b/lxqt-session/src/procreaper.cpp
index 7c7512c..bb92196 100644
--- a/lxqt-session/src/procreaper.cpp
+++ b/lxqt-session/src/procreaper.cpp
@@ -31,7 +31,7 @@ void ProcReaper::run()
if (pid <= 0)
{
QMutexLocker guard{&mMutex};
- mWait.wait(&mMutex, std::chrono::milliseconds(200));
+ mWait.wait(&mMutex, std::chrono::seconds(1));
}
int status; |
200 ms didn't have a tangible effect here but, yes,1 sec seems better. |
600ca8d
to
e347084
Compare
There was even next typo with variable hiding :( ... fixed $ git diff
diff --git a/lxqt-session/src/procreaper.cpp b/lxqt-session/src/procreaper.cpp
index bb92196..a8a56b8 100644
--- a/lxqt-session/src/procreaper.cpp
+++ b/lxqt-session/src/procreaper.cpp
@@ -35,7 +35,7 @@ void ProcReaper::run()
}
int status;
- pid_t pid = ::waitpid(-1, &status, WNOHANG);
+ pid = ::waitpid(-1, &status, WNOHANG);
if (pid < 0)
{
if (ECHILD != errno) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested in Linux. It performed as described.
@palinek Consider adding a license notice in each source file.
e347084
to
d198b91
Compare
Done. |
Should I merge this? |
Please do! It's good news for 0.17. |
This breaks applications that are expected to live longer than the GUI session (e.g., tmux). Steps to reproduce:
Expected result: the tmux session persists and can be attached later Actual result: the tmux session is gone |
@yan12125 |
How can the session distinguish which process is supposed to live longer than the GUI session? |
It can't, unless there's an "inside info" somewhere. The problem might be avoided if we can add a method for the user to exclude some apps in a new section of LXQt Session Settings. Also, a few apps may be excluded in the code. Just a vague suggestion... |
Argh, possibly because I was sleepy. Created #376. |
Ref: lxqt/lxqt-session#374 Also updates the AUR package from archlinuxcn
This is another approach to "correctly stop all children upon session exit":
This logic is currently implemented only for Linux (proper if/ifdefs used), but based on goole-fu, there are possibilities to implement this for BSD also
https://stackoverflow.com/questions/62365978/get-a-list-of-child-processes-from-parent-process-in-c-and-c-cross-platform
https://unix.stackexchange.com/questions/149319/new-parent-process-when-the-parent-process-dies
@jsm222 Could you have a look for the BSD changes?