<?xml version="1.0"?>
<paste-with-annotations>
  <paste>
    <number>
      <integer>84375</integer>
    </number>
    <user>
      <string>cgay</string>
    </user>
    <title>
      <string>cgi-script-responder</string>
    </title>
    <contents>
      <string>define method cgi-script-responder
    (script :: &lt;locator&gt;)
  let command = as(&lt;string&gt;, script);
  log-debug(&quot;cgi-script-responder(%=)&quot;, command);
  let request :: &lt;request&gt; = current-request();
  let env :: &lt;string-table&gt; = make-cgi-environment(script);

  for (value keyed-by key in env)
    log-debug(&quot;  %s: %s&quot;, key, value);
  end;
  
  let (exit-code, signal, child, stdin, stdout)
    = run-application(list(command),
                      asynchronous?: #t,
                      under-shell?: #f,
                      environment: env,
                      // TODO: see if RFC sez anything about this
                      //working-directory: foo,
                      input: stream:,
                      output: stream:,
                      error: null:,     // temp
                      
                      // Windows options, ignored on posix systems
                      activate?: #f,
                      minimize?: #t,
                      hide?: #t);
  block ()
    if (exit-code ~= 0)
      log-error(&quot;CGI failed to launch: %s, exit-code: %s, signal: %s&quot;,
                command, exit-code, signal);
    else
      close(stdin);  // temp
      output(read-to-end(stdout));
    end;
  cleanup
    log-debug(&quot;CGI waiting: %s&quot;, command);
    let (exit-code, signal) = wait-for-application-process(child);
    log-debug(&quot;CGI terminated: %s, exit-code: %s, signal: %s&quot;,
              command, exit-code, signal);
  end;
end method cgi-script-responder;
</string>
    </contents>
    <universal-time>
      <integer>3457864446</integer>
    </universal-time>
    <channel>
      <string>#dylan</string>
    </channel>
    <colorization-mode>
      <string>None</string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <keyword>TRUE</keyword>
    </is-unicode>
    <deletion-requested>
      <null/>
    </deletion-requested>
    <deletion-requested-email>
      <null/>
    </deletion-requested-email>
    <expiration-time>
      <null/>
    </expiration-time>
  </paste>
</paste-with-annotations>
