This adds a check for setproctitle and for the (linux) prctl
PR_SET_NAME. If setproctitle is not available, on linux we provide an
implementation that use prctl (taken from tmux compat layer.)
keep mark_nonblock in utils.c, as otherwise the build for the regress
suite will fail (mark_nonblock needs fatal which is in gmid.c, and
we can't link gmid.o with the regress suite...)
I got bitten by the scope visibility rules. After the end of the
block, the path variable is no longer valid, and in fact later
load_vhosts fails to open that (because the buffer gets invalidated)
Now that I got rid of the enum+switch, adding more state is easier.
Before, we used an hack to remember if we had read the CGI reply or
not (c->code = -1).
This introduces a new state, handle_cgi_reply that reads the CGI
script reply, logs it, and only then switches to handle_cgi.
handle_cgi itself is cleaner, now it only reads into c->sbuf and send
what it had red.
We even get, almost for free, the 42 error. If read exists with -1 or
0 from in handle_cgi_reply, we return a proper error to the client.
We can extend this further in the future and also try to validate the
CGI reply (for now we're only looking for a \n).
So we don't re-enter the handle_handsahke and re-do the loop on
fnmatch etc. This way, once we're successfully past the handshake,
we'll re-enter no handle_open_conn.
FRC3875 says that if the query does not contain any unecnoded "="
characters, we SHOULD treat the query string as a "search-string",
split in on "+" and add every word to the CGI argv.
In launch_cgi it's too late because iri->query is the *decoded* query!
I have in mind some refactoring around how we decode things, so this
is postponed.
Oh my, this is such a stupid mistake. It went undiscovered only
because I always used CGI scripts on the first vhost (and hence the
offset would be 0) and never on the others.