-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Get bundle exec
respecting proc titles
#7140
Conversation
This definitely seems like the right approach to me. |
spec/commands/exec_spec.rb
Outdated
@@ -55,6 +55,13 @@ | |||
expect(out).to eq("hi") | |||
end | |||
|
|||
it "respects custom process title when loading through ruby" do | |||
create_file "Gemfile" | |||
create_file "a.rb", 'Process.setproctitle("1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16"); puts `ps -eo args | grep [1]-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16`' |
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'm shelling out to ps
in order to test this, since I couldn't think of a better way.
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 can't think of another way to do it, either. It may be worth adding a brief comment explaining how it's testing it, for folks less familiar with *nix tools.
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.
Thank you, I'll add a little comment. 👍
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 added a local variable with a long name, to explain what the test script is about 😃
ae16be3
to
a7d5467
Compare
Thanks for having a look @duckinator. I'll get this in! @bundlerbot r+ |
7140: Get `bundle exec` respecting proc titles r=deivid-rodriguez a=deivid-rodriguez ### What was the end-user problem that led to this PR? The problem was that `bundle exec` would not respect custom proctitles inside scripts. ### What was your diagnosis of the problem? My diagnosis was that the previous code was using the third form of `Kernel.exec`, documented as: > In the third form (exec(["command", "argv0"], "arg1", ...)), starting a two-element array at the beginning of the command, the first element is the command to be executed, and the second argument is used as the argv[0] value, which may show up in process listings. See https://ruby-doc.org/core-2.6.3/Kernel.html#method-i-exec. However, since this form messes with proc titles, it seems to affect scripts settting their own proc titles. ### What is your fix for the problem, implemented in this PR? My fix is to use the simpler form: > In the second form (exec("command1", "arg1", ...)), the first is taken as a command name and the rest are passed as parameters to command with no shell expansion. We were not passing any special proc title, so I don't think we need the third form, and this simpler form allows custom proc titles inside scripts to work just fine. ### Why did you choose this fix out of the possible options? I chose this fix because I couldn't figure out a better one. Closes #7135. Co-authored-by: David Rodríguez <[email protected]>
Build succeeded |
What was the end-user problem that led to this PR?
The problem was that
bundle exec
would not respect custom proctitles inside scripts.What was your diagnosis of the problem?
My diagnosis was that the previous code was using the third form of
Kernel.exec
, documented as:See https://ruby-doc.org/core-2.6.3/Kernel.html#method-i-exec.
However, since this form messes with proc titles, it seems to affect scripts settting their own proc titles.
What is your fix for the problem, implemented in this PR?
My fix is to use the simpler form:
We were not passing any special proc title, so I don't think we need the third form, and this simpler form allows custom proc titles inside scripts to work just fine.
Why did you choose this fix out of the possible options?
I chose this fix because I couldn't figure out a better one.
Closes #7135.