Use sigaction() without SA_RESTART rather than signal() so that we
don't block in NgRecvData() after receiving a signal. MFC after: 1 week
This commit is contained in:
parent
74bd6d9d66
commit
7042cfcdd6
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=80724
@ -77,7 +77,6 @@ static void
|
|||||||
Farewell(int sig)
|
Farewell(int sig)
|
||||||
{
|
{
|
||||||
ReceivedSignal = sig;
|
ReceivedSignal = sig;
|
||||||
signal(sig, SIG_DFL); /* If something makes us block... */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -469,6 +468,7 @@ main(int argc, char **argv)
|
|||||||
unsigned char response[1024];
|
unsigned char response[1024];
|
||||||
const char *prog, *provider, *acname;
|
const char *prog, *provider, *acname;
|
||||||
struct ngm_connect ngc;
|
struct ngm_connect ngc;
|
||||||
|
struct sigaction act;
|
||||||
int ch, cs, ds, ret, optF, optd, optn, sz, f;
|
int ch, cs, ds, ret, optF, optd, optn, sz, f;
|
||||||
const char *pidfile;
|
const char *pidfile;
|
||||||
|
|
||||||
@ -591,10 +591,14 @@ main(int argc, char **argv)
|
|||||||
if (!optF && optn)
|
if (!optF && optn)
|
||||||
NgSetErrLog(nglog, nglogx);
|
NgSetErrLog(nglog, nglogx);
|
||||||
|
|
||||||
signal(SIGHUP, Farewell);
|
memset(&act, '\0', sizeof act);
|
||||||
signal(SIGINT, Farewell);
|
act.sa_handler = Farewell;
|
||||||
signal(SIGQUIT, Farewell);
|
act.sa_flags = SA_RESETHAND;
|
||||||
signal(SIGTERM, Farewell);
|
sigemptyset(&act.sa_mask);
|
||||||
|
sigaction(SIGHUP, &act, NULL);
|
||||||
|
sigaction(SIGINT, &act, NULL);
|
||||||
|
sigaction(SIGQUIT, &act, NULL);
|
||||||
|
sigaction(SIGTERM, &act, NULL);
|
||||||
|
|
||||||
while (!ReceivedSignal) {
|
while (!ReceivedSignal) {
|
||||||
if (*provider)
|
if (*provider)
|
||||||
|
Loading…
Reference in New Issue
Block a user