Multiple simultaneous calls to exec prevent the program from proceeding

Viewed 37

I have a php file that is requested from 3 different browsers simultaneously and repeatedly. This php file starts a process using exec(). Given that the php file is requested several times, exec() also occurs repeatedly.

I got unwanted results after a while so I had to start testing.

This is what it looks like when it goes according to the instructions:

  1. php starts
  2. php calls exec()
  3. exe does its thing and returns
  4. php done

5/5 times it will be as above, but all of a sudden it will be like this instead:

  1. php starts
  2. php calls exec()
  3. exe does its thing and returns
  4. php does not proceed from exec, even though the child process has ended. (step 3)

The interesting thing is that when it gets stuck at exec, it is released when another request to the same script has been completed.

I can not figure out what's going on here. I really hope someone else has an idea

EDIT: (MORE DETAILS)

When the script finally continues from exec, exec returns without problem. Both the output and the return-status is as usual, non error.

The exe returns without problem, I know because it writes to a log. Then its parent (the php script) doesn’t continue, it waits. BUT, it later continues as mentioned earlier when another request to the same script has been completed. I dont know if it continues when the other entire script has reached the end or as soon as the exec part of the other script is done. But one of the scenarios happens.

I have a try catch, nothing gets thrown.

The exe files monitor different path’s in windows. When something happens in a directory they return. So when the php-script gets stuck at exec, at the exact time that I make a change/edit in a direcotry that another php-script child process is monitoring then the locked/stucked script finally continues (and it has the program output and everything’s alright)

0 Answers
Related