#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    5
    Rep Power
    0

    Beginner Ruby question


    Hi

    I am trying to determine if a process is running or not using this code. What is the right way to do this? Here is my attempt

    [1] pry(main)> if Process.getpgid(89707) !=1
    [1] pry(main)* puts "it got killed"
    [1] pry(main)* else
    [1] pry(main)* puts "it did not get killed"
    [1] pry(main)* end
    Errno::ESRCH: No such process
    from (pry):1:in `getpgid'
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    71
    Rep Power
    2
    When you call - Process.getpgid - it returns the pcocess group id.

    Your if statement shoud be

    Code:
    if Process.getpgid != 89707
    ...
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    5
    Rep Power
    0
    Originally Posted by G4143
    When you call - Process.getpgid - it returns the pcocess group id.

    Your if statement shoud be

    Code:
    if Process.getpgid != 89707
    ...
    Thank You. Almost obvious now that I see your answer

    P.S - How do I mark this as answered?

IMN logo majestic logo threadwatch logo seochat tools logo