Mercurial > pidgin
comparison src/proxy.c @ 13530:2e10680b7545
[gaim-migrate @ 15907]
Patch from Julien Bossart to change our DNS child liveness test to one
using waitpid instead of kill. This is still sort of a heuristic,
because we could conceivably have some *other* child with the same PID
(say, a sound fork), but that's reasonably unlikely and this check is
certainly more reliable than the previous check.
committer: Tailor Script <tailor@pidgin.im>
| author | Ethan Blanton <elb@pidgin.im> |
|---|---|
| date | Mon, 20 Mar 2006 18:11:29 +0000 |
| parents | 6ad9d666e824 |
| children | 3eba1e7458c7 |
comparison
equal
deleted
inserted
replaced
| 13529:43268b823440 | 13530:2e10680b7545 |
|---|---|
| 542 static int | 542 static int |
| 543 send_dns_request_to_child(pending_dns_request_t *req, dns_params_t *dns_params) | 543 send_dns_request_to_child(pending_dns_request_t *req, dns_params_t *dns_params) |
| 544 { | 544 { |
| 545 char ch; | 545 char ch; |
| 546 int rc; | 546 int rc; |
| 547 | 547 pid_t pid; |
| 548 /* Are you alive? */ | 548 |
| 549 if (kill(req->dns_pid, 0) != 0) { | 549 /* This waitpid might return the child's PID if it has recently |
| 550 * exited, or it might return an error if it exited "long | |
| 551 * enough" ago that it has already been reaped; in either | |
| 552 * instance, we can't use it. */ | |
| 553 if ((pid = waitpid (req->dns_pid, NULL, WNOHANG)) > 0) { | |
| 550 gaim_debug_warning("dns", | 554 gaim_debug_warning("dns", |
| 551 "DNS child %d no longer exists\n", req->dns_pid); | 555 "DNS child %d no longer exists\n", req->dns_pid); |
| 556 return -1; | |
| 557 } else if (pid < 0) { | |
| 558 gaim_debug_warning("dns", | |
| 559 "Wait for DNS child %d failed: %s\n", | |
| 560 req->dns_pid, strerror(errno)); | |
| 552 return -1; | 561 return -1; |
| 553 } | 562 } |
| 554 | 563 |
| 555 /* Let's contact this lost child! */ | 564 /* Let's contact this lost child! */ |
| 556 rc = write(req->fd_in, dns_params, sizeof(*dns_params)); | 565 rc = write(req->fd_in, dns_params, sizeof(*dns_params)); |
