Skip to content
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

Return Process::Waiter with pid in Process.detach #4566

Merged
merged 1 commit into from Apr 19, 2017

Conversation

@davishmcclurg
Copy link
Contributor

@davishmcclurg davishmcclurg commented Apr 19, 2017

This adds a pid method to threads returned by Process.detach,
as described in the open3.rb documentation. The thread is a
Process::Waiter to be consistent with standard Ruby.

I haven't worked in Java much before, so please let me know if there's
anything I'm missing.

Before:

>> JRUBY_VERSION
=> "9.1.4.0"
>> pid = Process.spawn('sleep 10')
=> 58487
>> thr = Process.detach(_)
=> #<Thread:0x45752059@(irb):3 run>
>> thr.pid
NoMethodError: undefined method `pid' for #<Thread:0x45752059@(irb):3 dead>

After:

>> JRUBY_VERSION
=> "9.1.9.0-SNAPSHOT"
>> pid = Process.spawn('sleep 10')
=> 59018
>> thr = Process.detach(_)
=> #<Process::Waiter:0x5acf93bb@(irb):3 run>
>> thr.pid
=> 59018
This adds a `pid` method to threads returned by `Process.detach`,
as described in the open3.rb documentation. The thread is a
`Process::Waiter` to be consistent with standard Ruby.

Before:

```
>> JRUBY_VERSION
=> "9.1.4.0"
>> pid = Process.spawn('sleep 10')
=> 58487
>> thr = Process.detach(_)
=> #<Thread:0x45752059@(irb):3 run>
>> thr.pid
NoMethodError: undefined method `pid' for #<Thread:0x45752059@(irb):3 dead>
```

After:

```
>> JRUBY_VERSION
=> "9.1.9.0-SNAPSHOT"
>> pid = Process.spawn('sleep 10')
=> 59018
>> thr = Process.detach(_)
=> #<Process::Waiter:0x5acf93bb@(irb):3 run>
>> thr.pid
=> 59018
```
@headius
Copy link
Member

@headius headius commented Apr 19, 2017

This appears to be the same way MRI implements Waiter#pid and the PR looks fine. Merging.

@headius headius merged commit 8568572 into jruby:master Apr 19, 2017
1 check was pending
1 check was pending
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
@headius headius added this to the JRuby 9.1.9.0 milestone Apr 19, 2017
@davishmcclurg davishmcclurg deleted the davishmcclurg:davishmcclurg/wait-thread-pid branch Oct 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.