Sign up ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free.

Inside a long running php process on a debian system, there is an exec statement that gets called thousands of times (~100000 times). The script does batch processing on images, 20 at a time. Part of this, it uses exec to call the imagemagick library's convert command line utility to extent an image.

The issue is that, after running for few hours and processing few tens of thousands of images, the program starts to fall through a while loop.. because exec can't fork a process, and the entire process quickly comes to a end with a lot of the images still in the processing queue.

I've looked around for the possible causes of exec can't fork warning, and can cross out these possibilities:

  1. permissions - I have 777 -R given to folders related to the process.
  2. resource unavailability - Network, Memory, CPU usage, Disk Free Space all seem fine.

It might be due to php's child process limit php -r "echo exec('ulimit -u');" getting consumed completely, but I am not sure.

So, how do I run a command line utility, wait for it to complete, make sure every resource the utility used is freed?

share|improve this question
1  
Any reason you cannot use PHP's ImageMagick library instead of using CLI functions via exec() calls? –  Mr Shunz Jun 12 '14 at 9:35
    
That's interesting question.. so I do something like this: convert -gravity center -extent 200x200. I've looked at imagemagick docs and couldn't figure how to do this.. there is the extentImage, setGravity and setImageExtent. I guess I have to use both setGravity and setImageExtent together. –  Prasanth Jun 12 '14 at 9:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.