title: Matplotlib subprocess/backend issue
body: <p>I want to plot (i.e. write a file) with matplotlib from a script that runs as a subprocess (launched by a python cgi-script from an apache server), but somehow either the plot isn't created or the server crashes depending on the backend I use. I think I should be using "agg", and the plot is created in that case, but the server crashes then (internal server error). Here's the log:</p>
  
  <pre><code>AH01215: /usr/lib/pymodules/python2.7/gtk-2.0/gtk/__init__.py:57: GtkWarning: could not open display, referer: http://localhost/
  AH01215:   warnings.warn(str(e), _gtk.Warning), referer: http://localhost/
  AH01215: /usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_gtk.py:49: GtkWarning: IA__gdk_cursor_new_for_display: assertion `GDK_IS_DISPLAY (display)' failed, referer: http://localhost/
  AH01215:   cursors.MOVE          : gdk.Cursor(gdk.FLEUR),, referer: http://localhost/
  malformed header from script 'submit.cgi': Bad header: ['/home/user/..., referer: http://localhost/
  </code></pre>
  
  <p>The cgi-script doens't depend on the output of the subprocess at the moment, so I don't really get the bad-header warning (and there is no such problem when not launching the subprocess). The beginning of the plot-script looks like this:</p>
  
  <pre><code>import string
  import sys
  import os
  from math import *
  import tempfile
  os.environ['MPLCONFIGDIR'] = tempfile.mkdtemp()
  import matplotlib
  matplotlib.use('Agg') 
  import matplotlib.pyplot as matplot
  from matplotlib import mpl
  </code></pre>
  
  <p>So far I only did rather simple plot with matplotlib and not as subprocesses, so I would really appreciate your help.</p>
  
  <p>PS: I'm using ubuntu 11.04 and apache2</p>