2 mtr -- a network diagnostic tool
3 Copyright (C) 2016 Matt Kimball
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License version 2 as
7 published by the Free Software Foundation.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, Inc.,
16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include <sys/select.h>
28 Wait for either a request from the command stream or
29 for the probe results to be passed from the ICMP service
32 void wait_for_activity(
33 struct command_buffer_t
*command_buffer
,
34 struct net_state_t
*net_state
)
42 FD_SET(command_buffer
->command_stream
, &read_set
);
43 nfds
= command_buffer
->command_stream
+ 1;
45 FD_SET(net_state
->platform
.thread_out_pipe_read
, &read_set
);
46 if (net_state
->platform
.thread_out_pipe_read
>= nfds
) {
47 nfds
= net_state
->platform
.thread_out_pipe_read
+ 1;
52 select(nfds
, &read_set
, NULL
, NULL
, NULL
);
54 if (ready_count
!= -1) {
59 EINTR and EAGAIN simply mean that the select should
62 if (errno
!= EINTR
&& errno
!= EAGAIN
) {
63 error(EXIT_FAILURE
, errno
, "unexpected select error");