- gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, prog, "write");
- exit (1);
- }
- }
-#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;