0

I am using dns_get_record inside a user defined function and do some process inside user defined function.Sometimes dns_get_record takes very long time to process if domain is dead.

Is there a way Php function can return a value if the total process takes more than 30 sec or so. Basically I would like to return control to main program if total user defined function execution time is more than 30 secs. How I can do this in Php?

Abhilash
  • 206
  • 3
  • 18

1 Answers1

0

As v2solutions.com suggests, you could use set_time_limit() but the whole process would terminate with a fatal error.

On the other hand, you could spawn a new process with forking or by starting a new process altogether (alternative option), or a new thread, and monitor this subprocess/thread from your main loop.

Community
  • 1
  • 1
RandomSeed
  • 29,301
  • 6
  • 52
  • 87