(handleintr): Move to main.c. Internal linkage. Remove empty
handle.c (interrupt): Internal linkage. (interrupt): Use proper type for access from signal handler. (intr): Don't increment to set, it's unobvious and it could overflow.
This commit is contained in:
parent
5c02a0aefc
commit
87ace6afe4
3 changed files with 18 additions and 62 deletions
|
@ -69,9 +69,9 @@ HANDLE hStdIn;
|
|||
#define RETRY 3
|
||||
|
||||
int eight_bit_clean;
|
||||
int interrupt;
|
||||
int sock;
|
||||
|
||||
static volatile sig_atomic_t interrupt;
|
||||
static void intr(int sig);
|
||||
|
||||
|
||||
|
@ -332,7 +332,7 @@ main(int ac, char **av)
|
|||
static void
|
||||
intr(int sig)
|
||||
{
|
||||
interrupt++;
|
||||
interrupt = 1;
|
||||
#ifdef _WIN32
|
||||
signal(SIGINT, intr);
|
||||
#endif
|
||||
|
@ -340,3 +340,19 @@ intr(int sig)
|
|||
signal(SIGINT, intr);
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
handleintr(int s)
|
||||
{
|
||||
if (interrupt) {
|
||||
/* tacky, but it works */
|
||||
#if !defined(_WIN32)
|
||||
if (write(s, "\naborted\n", 1 + 7 + 1) <= 0)
|
||||
#else
|
||||
if (send(s, "\naborted\n", 1 + 7 + 1, 0) <= 0)
|
||||
#endif
|
||||
return 0;
|
||||
interrupt = 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue