Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 658301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:55:06+00:00 2026-05-13T22:55:06+00:00

I have a ruby script that does a few perforce operations (through the scripting

  • 0

I have a ruby script that does a few perforce operations (through the scripting API) then simply ends:

def foo()
  ...
end

def bar()
  ...
end

foo()
bar()
puts __LINE__
exit 0
#end of file

…and while the LINE will print out, the process never ends, whether the exit(0) is there or not. This is ruby 1.8.6, primarily on the mac, but I’m seeing this on the PC as well.

I’m doing the usual google poking around, but hoped there might be a voice of experience here to bank on. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T22:55:06+00:00Added an answer on May 13, 2026 at 10:55 pm

    I’m not at all familiar with perforce, but the culprit might be an at_exit method that’s stuck in a loop for some reason. Observe the behavior using irb, for instance:

    $ irb
    irb(main):001:0> require 'time'
    => true
    irb(main):002:0> at_exit { puts Time.now; sleep 10; puts Time.now }
    => #<Proc:0xb7656f64@(irb):2>
    irb(main):003:0> exit
    Fri Mar 12 19:46:25 -0500 2010
    Fri Mar 12 19:46:35 -0500 2010
    

    To confirm whether an at_exit function is causing the process to hang, you can try hooking into at_exit. Note that the #{caller} will display the stack trace of who called at_exit:

    def at_exit &block
        @at_exit_counter ||= 0
        puts "at_exit #{@at_exit_counter} called"
        s = "Calling at_exit ##{@at_exit_counter} from #{caller}"
        super { puts s; block.call() }
        @at_exit_counter += 1
    end
    
    at_exit { puts "I'll never return"; sleep 1 while true; }
    at_exit { puts 'I am about to leave.' }
    
    def do_cleanup
        puts "Cleaning..."
        at_exit { puts 'Cleaning up before exit...' }
    
    end
    
    do_cleanup
    

    which outputs:

    at_exit 0 called
    at_exit 1 called
    Cleaning...
    at_exit 2 called
    Calling at_exit #2 from exitcheck.rb:14:in `do_cleanup'exitcheck.rb:18
    Cleaning up before exit...
    Calling at_exit #1 from exitcheck.rb:10
    I am about to leave.
    Calling at_exit #0 from exitcheck.rb:9
    I'll never return
    

    and never returns.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 397k
  • Answers 397k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use trim to remove blank characters in the beginning and… May 15, 2026 at 3:22 am
  • Editorial Team
    Editorial Team added an answer I like to group the items first using an array… May 15, 2026 at 3:22 am
  • Editorial Team
    Editorial Team added an answer I think it should look like this: $ipaddr = $_SERVER['REMOTE_ADDR'];… May 15, 2026 at 3:22 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.