fork and modifying variables inside the new process

Discussion in 'Ruby' started by Kurt M. Dresner, Aug 16, 2003.

  1. irb(main):001:0> a = true
    => true
    irb(main):002:0> fork do
    irb(main):003:1* a = false
    irb(main):004:1> end
    => 2525
    irb(main):005:0> a
    => true


    Why is this so? What is the point of having my mutexes if I can't
    manipulate the data anyway?

    -Kurt
     
    Kurt M. Dresner, Aug 16, 2003
    #1
    1. Advertisements

  2. Kurt M. Dresner

    mgarriss Guest

    Fork creates a whole new heavy process. I think you are looking for
    Thread. Try something like:

    Thread.new {
    a = false
    }
     
    mgarriss, Aug 16, 2003
    #2
    1. Advertisements

  3. The problem is that I want to call exec inside the new process, as well
    as being able to send it things like SIGSTOP and SIGCONT.

    Is there a way I can do this?

    -Kurt
     
    Kurt M. Dresner, Aug 17, 2003
    #3
  4. Actually it turns out I don't need that, I'm ok.

    sorry,

    Kurt
     
    Kurt M. Dresner, Aug 17, 2003
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.