Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SIGQUIT summary support similar to ping #185

Merged
merged 2 commits into from
Jun 27, 2020

Conversation

laddp
Copy link
Contributor

@laddp laddp commented Jun 12, 2020

ping supports printing out an intermediate summary of results and resuming via SIGQUIT (ctrl-\). fping currently prints out summary statistics only for hosts responding. This allows a summary to be output of all hosts without terminating the run.

Sample output:

fping -g 192.168.42.210 192.168.42.212 -l
192.168.42.211 : [0], 84 bytes, 1.00 ms (1.00 avg, 0% loss)
192.168.42.211 : [1], 84 bytes, 2.40 ms (1.70 avg, 0% loss)
192.168.42.211 : [2], 84 bytes, 0.93 ms (1.44 avg, 0% loss)
192.168.42.211 : [3], 84 bytes, 1.31 ms (1.41 avg, 0% loss)
ICMP Host Unreachable from 192.168.42.150 for ICMP Echo sent to 192.168.42.212
ICMP Host Unreachable from 192.168.42.150 for ICMP Echo sent to 192.168.42.212
ICMP Host Unreachable from 192.168.42.150 for ICMP Echo sent to 192.168.42.212
ICMP Host Unreachable from 192.168.42.150 for ICMP Echo sent to 192.168.42.212
ICMP Host Unreachable from 192.168.42.150 for ICMP Echo sent to 192.168.42.210
ICMP Host Unreachable from 192.168.42.150 for ICMP Echo sent to 192.168.42.210
ICMP Host Unreachable from 192.168.42.150 for ICMP Echo sent to 192.168.42.210
ICMP Host Unreachable from 192.168.42.150 for ICMP Echo sent to 192.168.42.210
192.168.42.211 : [4], 84 bytes, 1.03 ms (1.33 avg, 0% loss)
^\
[18:56:16]
192.168.42.210 : xmt/rcv/%loss = 5/0/100%
192.168.42.211 : xmt/rcv/%loss = 5/5/0%, min/avg/max = 0.93/1.33/2.40
192.168.42.212 : xmt/rcv/%loss = 4/0/100%
192.168.42.211 : [5], 84 bytes, 1.12 ms (1.29 avg, 0% loss)
^C
192.168.42.210 : xmt/rcv/%loss = 6/0/100%
192.168.42.211 : xmt/rcv/%loss = 6/6/0%, min/avg/max = 0.93/1.29/2.40
192.168.42.212 : xmt/rcv/%loss = 6/0/100%

src/fping.c Outdated
@@ -252,6 +252,8 @@ int socket6 = -1;
int hints_ai_family = AF_UNSPEC;
#endif

volatile int status_snapshot = 0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "volatile" is wrong here. It is a qualifier reserved for embedded programs where the variable's value can change without the compiler knowing (memory-mapped IO, etc.).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Values changed in signal handlers also fall in that class - the variable may be changed outside of the normal flow of execution that the compiler expects. Signal handlers are processed asynchronously from the main flow of execution.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I learned something :) But then, shouldn't it be of type sig_atomic_t ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to be cross-platform correct (I think sig_atomic_t == int o most platforms, but TIL something too :) ) I'll update the PR and add it to this commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok updated to use sig_atomic_t.

Think I got the whole squash commit thing right...

@schweikert
Copy link
Owner

Thanks!

@schweikert schweikert merged commit 5eff605 into schweikert:develop Jun 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants