PHP fork and getting the returned value.

Discussion in 'PHP' started by brain_freeze, Oct 26, 2010.

  1. #1
    Hi. I was trying to make my php script a bit faster by using multithreading so i forked some children that calculate some 2d strings. The problem is that i need to combine those 2d strings in the parent process but i dont know how to get them. Could i return their starting address ors sth or do they get destroyed after the child exits?
     
    brain_freeze, Oct 26, 2010 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    How are you forking new processes? This is getting into some very complex coding. I wrote a multi-process script to allow this a few years ago. Keeping track of children processes was one of the more difficult aspects of multi-threading/multi-processing with php. In the end I ended up using a sqlite database to pass parameters to and from the parent and its children. You could also use memcache or another caching mechanism, APC probably wont work.

    Need to know more about how your going doing this before I can help more.
     
    jestep, Oct 26, 2010 IP