File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change 33
33
#include <netdb.h>
34
34
#include <netinet/in.h>
35
35
#include <signal.h>
36
+ #include <stdbool.h>
36
37
#include <sys/socket.h>
37
38
38
39
static const char * _simulator_version = "1.0.0" ;
@@ -42,6 +43,7 @@ static const char* _simulator_version = "1.0.0";
42
43
int data_len ;
43
44
int commfd ;
44
45
46
+ static volatile sig_atomic_t sigint_called = false;
45
47
static int sockfd ;
46
48
47
49
int get_usb_message_socket (uint8_t * input )
@@ -72,7 +74,7 @@ void simulate_firmware_execution(const uint8_t* input)
72
74
73
75
static void _int_handler (int _signum )
74
76
{
75
- printf ( "\n\nGot Ctrl-C, exiting\n\n" ) ;
77
+ sigint_called = true ;
76
78
close (sockfd );
77
79
}
78
80
@@ -158,6 +160,9 @@ int main(int argc, char* argv[])
158
160
while (1 ) {
159
161
if ((commfd = accept (sockfd , (struct sockaddr * )& serv_addr , (socklen_t * )& serv_addr_len )) <
160
162
0 ) {
163
+ if (sigint_called ) {
164
+ printf ("\nGot Ctrl-C, exiting\n" );
165
+ }
161
166
perror ("accept" );
162
167
return 1 ;
163
168
}
You can’t perform that action at this time.
0 commit comments