# Process.waitpid(external pid)

**URL:** <https://www.ruby-forum.com/t/process-waitpid-external-pid/180308>\
**Category:** Ruby\
**Created:** [December 17, 2009, 3:41am UTC](https://www.ruby-forum.com/t/process-waitpid-external-pid/180308 "2009-12-17T03:41:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [December 17, 2009, 3:41am UTC](https://www.ruby-forum.com/t/process-waitpid-external-pid/180308/1 "2009-12-17T03:41:52Z")

</div>

Anybody know of a way in ruby to #waitpid on a non child process?

irb(main):001:0\> Process.waitpid 32550  
Errno::ECHILD: No child processes

[this is possible in doze with the win32-process gem, wondering about  
linux now].  
Thanks!  
-r

---

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [December 17, 2009, 3:50am UTC](https://www.ruby-forum.com/t/process-waitpid-external-pid/180308/2 "2009-12-17T03:50:36Z")

</div>

On 2009-12-17, Roger P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Anybody know of a way in ruby to #waitpid on a non child process?

It seems unlikely in general – waitpid, in POSIX land, really is  
specific  
to your children.

Usually, the idiom is to send them signal 0 until it fails.

-s

---

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [December 18, 2009, 11:06pm UTC](https://www.ruby-forum.com/t/process-waitpid-external-pid/180308/3 "2009-12-18T23:06:11Z")

</div>

> > Anybody know of a way in ruby to #waitpid on a non child process?
> 
> It seems unlikely in general – waitpid, in POSIX land, really is  
> specific  
> to your children.
> 
> Usually, the idiom is to send them signal 0 until it fails.

Excellent suggestion.  
I have created a gem that does just that.

$ gem install wait\_pid

provides you with this ruby code

require ‘wait\_pid’  
WaitPid.wait\_pid 1234

and this binary command

$ wait\_pid pid\_number

Works in both windows and linux.

Cheers!  
-r

> **[GitHub - rdp/wait\_pid: the wait\_pid command -- (ruby gem/binary for waiting...](https://github.com/rdp/wait_pid)**
>
> the wait\_pid command -- (ruby gem/binary for waiting on any arbitrary external pid, works on doze/linux) - GitHub - rdp/wait\_pid: the wait\_pid command -- (ruby gem/binary for waiting on any arbitra...
