(main, intr) [!_WIN32]: signal() is a portability headache. Switch to
sigaction().
This commit is contained in:
parent
1ec32d97c4
commit
75a511a749
1 changed files with 11 additions and 9 deletions
|
@ -88,6 +88,7 @@ main(int ac, char **av)
|
||||||
int bRedirected = 0;
|
int bRedirected = 0;
|
||||||
char unamebuf[128];
|
char unamebuf[128];
|
||||||
#else
|
#else
|
||||||
|
struct sigaction sa;
|
||||||
fd_set mask;
|
fd_set mask;
|
||||||
fd_set savemask;
|
fd_set savemask;
|
||||||
int retry = 0;
|
int retry = 0;
|
||||||
|
@ -214,10 +215,12 @@ main(int ac, char **av)
|
||||||
FD_ZERO(&mask);
|
FD_ZERO(&mask);
|
||||||
FD_SET(0, &savemask);
|
FD_SET(0, &savemask);
|
||||||
FD_SET(sock, &savemask);
|
FD_SET(sock, &savemask);
|
||||||
#endif
|
sigemptyset(&sa.sa_mask);
|
||||||
(void)signal(SIGINT, intr);
|
sa.sa_flags = 0;
|
||||||
#ifndef _WIN32
|
sa.sa_handler = intr;
|
||||||
(void)signal(SIGPIPE, SIG_IGN);
|
sigaction(SIGINT, &sa, NULL);
|
||||||
|
sa.sa_handler = SIG_IGN;
|
||||||
|
sigaction(SIG_IGN, &sa, NULL);
|
||||||
while (FD_ISSET(sock, &savemask)) {
|
while (FD_ISSET(sock, &savemask)) {
|
||||||
mask = savemask;
|
mask = savemask;
|
||||||
n = select(sock + 1, &mask, NULL, NULL, NULL);
|
n = select(sock + 1, &mask, NULL, NULL, NULL);
|
||||||
|
@ -250,7 +253,9 @@ main(int ac, char **av)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else /* _WIN32 */
|
||||||
|
signal(SIGINT, intr);
|
||||||
|
|
||||||
bRedirected = 0;
|
bRedirected = 0;
|
||||||
tm.tv_sec = 0;
|
tm.tv_sec = 0;
|
||||||
tm.tv_usec = 1000;
|
tm.tv_usec = 1000;
|
||||||
|
@ -323,7 +328,7 @@ main(int ac, char **av)
|
||||||
}
|
}
|
||||||
if (bRedirected == 0)
|
if (bRedirected == 0)
|
||||||
CloseHandle(hStdIn);
|
CloseHandle(hStdIn);
|
||||||
#endif
|
#endif /* _WIN32 */
|
||||||
ioq_drain(&server);
|
ioq_drain(&server);
|
||||||
(void)close(sock);
|
(void)close(sock);
|
||||||
return 0; /* Shut the compiler up */
|
return 0; /* Shut the compiler up */
|
||||||
|
@ -336,9 +341,6 @@ intr(int sig)
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
signal(SIGINT, intr);
|
signal(SIGINT, intr);
|
||||||
#endif
|
#endif
|
||||||
#ifdef hpux
|
|
||||||
signal(SIGINT, intr);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue