-
Notifications
You must be signed in to change notification settings - Fork 149
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
Support multi-user environments #49
base: master
Are you sure you want to change the base?
Conversation
When counting the number of running tmux processes, count only those that belong to the current user. `tmux a` shows as a separate process (must be the client process) and thus needs to be excluded from the calculation as well. The previous exclusion of `tmux source` was also incorporated.
scripts/helpers.sh
Outdated
# 2) `tmux a` (which shows an additional process) | ||
|
||
ps -Ao "command pid uid" |\ | ||
grep $UID |\ |
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.
I propose using ps -u $UID
. grep $UID
can match tmux process pid
.
|
||
ps -Ao "command pid uid" |\ | ||
grep $UID |\ | ||
grep -E '^tmux' |\ |
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.
Why add -E
flag?
The ps -u needs to be tested but i agree. The E is to be explicit about using regular expressions. Do you know of a reason not to use it?
… On May 1, 2018, at 9:18 AM, Bruno Sutic ***@***.***> wrote:
@bruno- commented on this pull request.
In scripts/helpers.sh:
> @@ -23,10 +23,14 @@ current_tmux_server_pid() {
}
all_tmux_processes() {
- # ignores `tmux source-file .tmux.conf` command used to reload tmux.conf
- ps -Ao "command pid" |
- \grep "^tmux" |
- \grep -v "^tmux source"
+ # finds all tmux processes for the current user ignoring the following:
+ # 1) `tmux source-file .tmux.conf` (used to reload tmux.conf)
+ # 2) `tmux a` (which shows an additional process)
+
+ ps -Ao "command pid uid" |\
+ grep $UID |\
+ grep -E '^tmux' |\
Why add -E flag?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Hi @bruno- , I took your advice and changed the code as you suggested. |
Can this change be merged? It's critical in a multi-user environment. |
The pid the `grep -v` is trying to eliminate is not at the end of the line. `all_tmux_processes` produces the following output (for example): ``` tmux 32069 29270 ``` Here the first number is the pid and the second -- the uid. So, since the idea of `number_tmux_processes_except_current_server` is to eliminate 32069 from consideration, it should look for "<SPACE>PID<SPACE>".
This is logical because we're increasing verbosity by setting the value to 2. At 1, the debug is on but the user is not interrupted by the status line messages.
Hi! Why this PR was not accepted? Is not finished? It'd be very useful to solve #48 since I think it's a common use case to share resources among co-workers, where multiple tmux sessions might be alive for different users... |
@cgr71ii this PR adds features that are outside the original scope. Also, some comments/questions were not addressed. If someone can make a clean, minimal change that addresses this problem I'll review the PR and merge if all is ok. |
When counting the number of running tmux processes, count only those
that belong to the current user.
tmux a
shows as a separate process (must be the client process) andthus needs to be excluded from the calculation as well. The previous
exclusion of
tmux source
was also incorporated.