diff options
Diffstat (limited to 'serverloop.c')
-rw-r--r-- | serverloop.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/serverloop.c b/serverloop.c index 69304b5fa..7e373f01b 100644 --- a/serverloop.c +++ b/serverloop.c | |||
@@ -280,6 +280,7 @@ wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp, int *maxfdp, | |||
280 | struct timeval tv, *tvp; | 280 | struct timeval tv, *tvp; |
281 | int ret; | 281 | int ret; |
282 | int client_alive_scheduled = 0; | 282 | int client_alive_scheduled = 0; |
283 | int program_alive_scheduled = 0; | ||
283 | 284 | ||
284 | /* | 285 | /* |
285 | * if using client_alive, set the max timeout accordingly, | 286 | * if using client_alive, set the max timeout accordingly, |
@@ -317,6 +318,7 @@ wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp, int *maxfdp, | |||
317 | * the client, try to get some more data from the program. | 318 | * the client, try to get some more data from the program. |
318 | */ | 319 | */ |
319 | if (packet_not_very_much_data_to_write()) { | 320 | if (packet_not_very_much_data_to_write()) { |
321 | program_alive_scheduled = child_terminated; | ||
320 | if (!fdout_eof) | 322 | if (!fdout_eof) |
321 | FD_SET(fdout, *readsetp); | 323 | FD_SET(fdout, *readsetp); |
322 | if (!fderr_eof) | 324 | if (!fderr_eof) |
@@ -362,8 +364,16 @@ wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp, int *maxfdp, | |||
362 | memset(*writesetp, 0, *nallocp); | 364 | memset(*writesetp, 0, *nallocp); |
363 | if (errno != EINTR) | 365 | if (errno != EINTR) |
364 | error("select: %.100s", strerror(errno)); | 366 | error("select: %.100s", strerror(errno)); |
365 | } else if (ret == 0 && client_alive_scheduled) | 367 | } else { |
366 | client_alive_check(); | 368 | if (ret == 0 && client_alive_scheduled) |
369 | client_alive_check(); | ||
370 | if (!compat20 && program_alive_scheduled && fdin_is_tty) { | ||
371 | if (!fdout_eof) | ||
372 | FD_SET(fdout, *readsetp); | ||
373 | if (!fderr_eof) | ||
374 | FD_SET(fderr, *readsetp); | ||
375 | } | ||
376 | } | ||
367 | 377 | ||
368 | notify_done(*readsetp); | 378 | notify_done(*readsetp); |
369 | } | 379 | } |
@@ -407,7 +417,8 @@ process_input(fd_set *readset) | |||
407 | if (!fdout_eof && FD_ISSET(fdout, readset)) { | 417 | if (!fdout_eof && FD_ISSET(fdout, readset)) { |
408 | errno = 0; | 418 | errno = 0; |
409 | len = read(fdout, buf, sizeof(buf)); | 419 | len = read(fdout, buf, sizeof(buf)); |
410 | if (len < 0 && (errno == EINTR || errno == EAGAIN)) { | 420 | if (len < 0 && (errno == EINTR || |
421 | (errno == EAGAIN && !child_terminated))) { | ||
411 | /* do nothing */ | 422 | /* do nothing */ |
412 | #ifndef PTY_ZEROREAD | 423 | #ifndef PTY_ZEROREAD |
413 | } else if (len <= 0) { | 424 | } else if (len <= 0) { |
@@ -425,7 +436,8 @@ process_input(fd_set *readset) | |||
425 | if (!fderr_eof && FD_ISSET(fderr, readset)) { | 436 | if (!fderr_eof && FD_ISSET(fderr, readset)) { |
426 | errno = 0; | 437 | errno = 0; |
427 | len = read(fderr, buf, sizeof(buf)); | 438 | len = read(fderr, buf, sizeof(buf)); |
428 | if (len < 0 && (errno == EINTR || errno == EAGAIN)) { | 439 | if (len < 0 && (errno == EINTR || |
440 | (errno == EAGAIN && !child_terminated))) { | ||
429 | /* do nothing */ | 441 | /* do nothing */ |
430 | #ifndef PTY_ZEROREAD | 442 | #ifndef PTY_ZEROREAD |
431 | } else if (len <= 0) { | 443 | } else if (len <= 0) { |