fork and modifying variables inside the new process

Ask a Question related to Ruby, Design and Development.

  1. #1

    Default fork and modifying variables inside the new process

    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 Guest

  2. Similar Questions and Discussions

    1. Flash OCX inside Visual Basic app- passing variables
      Hi, can a variable only be passed by visual basic to the _root timeline of a flash movie playing in the ocx inside it? This will work in VB...
    2. Deleting or Modifying Session Variables in anothersession
      Is it possible to delete or clear session variable from another session? Here's my scenario. A user opens the public part of a web site which...
    3. setting variables inside a php class
      I am trying to change the value of a variable inside a class from one of its functions rather than the constructor, but it doesn't seem to work. ...
    4. Global variables and a forked process
      Does a forked process share the memory locations of the global variables from the parent process? Thanks in advance!
    5. fork, childs, zombies, start a process in the background without waiting for it
      Hi I have a parent program, that should loop (eternally), and start other programs without waiting for them, so many programs can be started at...
  3. #2

    Default Re: fork and modifying variables inside the new process

    Kurt M. Dresner wrote:
    >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
    >
    >
    >
    >
    Fork creates a whole new heavy process. I think you are looking for
    Thread. Try something like:

    Thread.new {
    a = false
    }


    mgarriss Guest

  4. #3

    Default Re: fork and modifying variables inside the new process

    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

    On Sun, Aug 17, 2003 at 07:57:51AM +0900, mgarriss wrote:
    > Kurt M. Dresner wrote:
    >
    > >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
    > >
    > >
    > >
    > >
    > Fork creates a whole new heavy process. I think you are looking for
    > Thread. Try something like:
    >
    > Thread.new {
    > a = false
    > }
    >
    >
    >======= End of Original Message =======<
    Kurt M. Dresner Guest

  5. #4

    Default Re: fork and modifying variables inside the new process

    Actually it turns out I don't need that, I'm ok.

    sorry,

    Kurt

    On Sun, Aug 17, 2003 at 08:09:20AM +0900, Kurt M. Dresner wrote:
    > 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
    >
    > On Sun, Aug 17, 2003 at 07:57:51AM +0900, mgarriss wrote:
    > > Kurt M. Dresner wrote:
    > >
    > > >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
    > > >
    > > >
    > > >
    > > >
    > > Fork creates a whole new heavy process. I think you are looking for
    > > Thread. Try something like:
    > >
    > > Thread.new {
    > > a = false
    > > }
    > >
    > >
    > >======= End of Original Message =======<
    >
    >======= End of Original Message =======<
    Kurt M. Dresner Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139