| 421 | |
| 422 | #if defined HAVE_SETENV || defined HAVE_PUTENV |
| 423 | static int read_arg_from_pipe(int fd, char *buf, int limit) |
| 424 | { |
| 425 | char *bp = buf, *eob = buf + limit - 1; |
| 426 | |
| 427 | while (1) { |
| 428 | int got = read(fd, bp, 1); |
| 429 | if (got != 1) { |
| 430 | if (got < 0 && errno == EINTR) |
| 431 | continue; |
| 432 | return -1; |
| 433 | } |
| 434 | if (*bp == '\0') |
| 435 | break; |
| 436 | if (bp < eob) |
| 437 | bp++; |
| 438 | } |
| 439 | *bp = '\0'; |
| 440 | |
| 441 | return bp - buf; |
| 442 | } |
| 443 | #endif |
| 444 | |
| 445 | void set_env_str(const char *var, const char *str) |