Forum Bugs

Zombies ... [prince] <defunct>

nathenharvey
We are running prince-6.0r4-1 on RedHat Linux.

Prince is being called from a Ruby on Rails application with the following command


/usr/bin/prince --input=html --server --log=/var/www/railsapps/releases/20080117203515/log/prince.log -s /var/www/railsapps/releases/20080117203515/public/stylesheets/print/prince.css --silent - -o -


We are running some performance / load tests and are seeing a huge number of zombie price processes:

mongrel 3010 2755 0 21:14 ? 00:00:00 [prince] <defunct>
mongrel 3011 2767 0 21:14 ? 00:00:00 [prince] <defunct>
mongrel 3012 2747 0 21:14 ? 00:00:00 [prince] <defunct>
mongrel 3015 2767 0 21:14 ? 00:00:00 [prince] <defunct>


These zombie processes filled our process table and we had to reboot the box.

Perhaps this issue is similar to the one discussed on in thread 341?


How do we prevent these zombie processes?
mikeday
Ensure that the stdin, stdout and stderr streams have been closed when the Prince process has finished. Can you paste the code that you are using to call Prince?
nathenharvey
Here's the code we're using.

    pdf = IO.popen(path, "w+")
    pdf.puts(string)
    pdf.close_write
    pdf.gets(nil)
mikeday
Adding pdf.close_read after the gets should solve the problem, as the process will hang around as a zombie until the stream has been closed. (This is a UNIX thing, not a Prince thing).

I guess you will need to capture the result of pdf.gets in a variable to return it as well, or the function won't be very useful. :)
nathenharvey
That fixed it, thanks. Here's the new code:

    pdf = IO.popen(path, "w+")
    pdf.puts(string)
    pdf.close_write
    result = pdf.gets(nil)
    pdf.close_read
    return result