* USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $Log: wcgi.c,v $
- * Revision 1.12 1996/01/09 10:46:49 adam
+ * Revision 1.13 1996/01/12 10:05:17 adam
+ * If script name ends with ';' HTTP/GET/Expires will be defined.
+ * The cgi interface only reads final handshake if response from
+ * server (shell) was zero-terminated [If it isn't it probably died].
+ *
+ * Revision 1.12 1996/01/09 10:46:49 adam
* New defines: LOGDIR/EGWDIR/CGIDIR set in Makefile.
*
* Revision 1.11 1996/01/08 08:42:19 adam
}
gw_log (GW_LOG_DEBUG, prog, "Reading response");
-#if 1
while ((data = read(linein, combuf, COMBUF)) > 0)
{
gw_log (GW_LOG_DEBUG, prog, "Got %d bytes", data);
gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, prog, "write");
exit (1);
}
+ gw_log (GW_LOG_DEBUG, prog, "writing ack");
+ if (write(lineout, "OK", 2) < 2)
+ gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, prog, "write");
}
-#else
-# if 1
- fcntl (linein, F_SETFL, O_NONBLOCK);
-# endif
- while (1)
- {
- fd_set s_input;
- struct timeval t;
- int r, eof_flag = 0;
-
- t.tv_sec = 10;
- t.tv_usec = 0;
- FD_ZERO(&s_input);
- FD_SET(linein, &s_input);
-# if 0
- FD_SET(1, &s_input);
-# endif
- gw_log (GW_LOG_DEBUG, prog, "select");
- r = select (linein + 1, &s_input, NULL, NULL, &t);
- if (r < 0)
- {
- gw_log (GW_LOG_ERRNO|GW_LOG_FATAL, prog, "select");
- exit(1);
- }
- if (r == 0 || FD_ISSET (linein, &s_input))
- {
- if (r == 0)
- gw_log (GW_LOG_DEBUG, prog, "poll");
- if ((data = read (linein, combuf, COMBUF)) > 0)
- {
- if (combuf[data-1] == '\0')
- {
- --data;
- eof_flag = 1;
- }
- gw_log (GW_LOG_DEBUG, prog, "Got %d bytes", data);
- if (data > 0 && write(1, combuf, data) < data)
- {
- gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, prog, "write");
- exit (1);
- }
- }
- else if (data == -1)
- {
- if (r > 0)
- {
- gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, prog, "read");
- exit (1);
- }
- gw_log (GW_LOG_DEBUG, prog, "poll read");
- }
- else
- break;
- }
- if (eof_flag)
- break;
- if (r > 0 && FD_ISSET (1, &s_input))
- {
- data = read (1, combuf, COMBUF);
- if (data == -1)
- {
- gw_log (GW_LOG_DEBUG|GW_LOG_ERRNO, prog, "stdout closed");
- break;
- }
- if (data == 0)
- {
- gw_log (GW_LOG_DEBUG, prog, "stdout closed");
- break;
- }
- gw_log (GW_LOG_DEBUG, prog, "stdout got %d bytes", data);
- }
- }
-#endif
-
-#if 1
- gw_log (GW_LOG_DEBUG, prog, "writing ack");
- if (write(lineout, "OK", 2) < 2)
- gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, prog, "write");
-#endif
gw_log (GW_LOG_DEBUG, prog, "Cleaning up.");
close(linein);
unlink(serverp);