When pppd receives SIGINT or SIGTERM it should handle it and not try to
restart interrupted syscall.
This change fixes problem that pppd cannot be terminated by SIGINT or
SIGTERM signal when pppd plugins are used.
Signed-off-by: Pali Rohár <pali@kernel.org>
if (red == 0)
break;
if (red < 0) {
if (red == 0)
break;
if (red < 0) {
+ if (errno == EINTR && !got_sigterm)
continue;
error("Can't read secret from %s: %m", promptprog);
readgood = -1;
continue;
error("Can't read secret from %s: %m", promptprog);
readgood = -1;
/* now wait for child to exit */
while (waitpid(kid, &wstat, 0) < 0) {
/* now wait for child to exit */
while (waitpid(kid, &wstat, 0) < 0) {
+ if (errno != EINTR || got_sigterm) {
warn("error waiting for %s: %m", promptprog);
break;
}
warn("error waiting for %s: %m", promptprog);
break;
}
FD_SET (sockfd, &readfds);
if (select (sockfd + 1, &readfds, NULL, NULL, &authtime) < 0)
{
FD_SET (sockfd, &readfds);
if (select (sockfd + 1, &readfds, NULL, NULL, &authtime) < 0)
{
+ if (errno == EINTR && !got_sigterm)
continue;
error("rc_send_server: select: %m");
memset (secret, '\0', sizeof (secret));
continue;
error("rc_send_server: select: %m");
memset (secret, '\0', sizeof (secret));
while(1) {
r = select(conn->discoverySocket+1, &readable, NULL, NULL, &tv);
while(1) {
r = select(conn->discoverySocket+1, &readable, NULL, NULL, &tv);
- if (r >= 0 || errno != EINTR) break;
+ if (r >= 0 || errno != EINTR || got_sigterm) break;
}
if (r < 0) {
error("select (waitForPADO): %m");
}
if (r < 0) {
error("select (waitForPADO): %m");
while(1) {
r = select(conn->discoverySocket+1, &readable, NULL, NULL, &tv);
while(1) {
r = select(conn->discoverySocket+1, &readable, NULL, NULL, &tv);
- if (r >= 0 || errno != EINTR) break;
+ if (r >= 0 || errno != EINTR || got_sigterm) break;
}
if (r < 0) {
error("select (waitForPADS): %m");
}
if (r < 0) {
error("select (waitForPADS): %m");
- if (padiAttempts > conn->discoveryAttempts) {
+ if (got_sigterm || padiAttempts > conn->discoveryAttempts) {
warn("Timeout waiting for PADO packets");
close(conn->discoverySocket);
conn->discoverySocket = -1;
warn("Timeout waiting for PADO packets");
close(conn->discoverySocket);
conn->discoverySocket = -1;
timeout = conn->discoveryTimeout;
do {
padrAttempts++;
timeout = conn->discoveryTimeout;
do {
padrAttempts++;
- if (padrAttempts > conn->discoveryAttempts) {
+ if (got_sigterm || padrAttempts > conn->discoveryAttempts) {
warn("Timeout waiting for PADS packets");
close(conn->discoverySocket);
conn->discoverySocket = -1;
warn("Timeout waiting for PADS packets");
close(conn->discoverySocket);
conn->discoverySocket = -1;
return NOT_AUTHENTICATED;
}
return NOT_AUTHENTICATED;
}
- while ((wait(&status) == -1) && errno == EINTR)
+ while ((wait(&status) == -1) && errno == EINTR && !got_sigterm)
;
if ((authenticated == AUTHENTICATED) && nt_key && !got_user_session_key) {
;
if ((authenticated == AUTHENTICATED) && nt_key && !got_user_session_key) {
+extern int got_sigterm; /* SIGINT or SIGTERM was received */
extern int hungup; /* Physical layer has disconnected */
extern int ifunit; /* Interface unit number */
extern char ifname[]; /* Interface name */
extern int hungup; /* Physical layer has disconnected */
extern int ifunit; /* Interface unit number */
extern char ifname[]; /* Interface name */
pfd.events = POLLIN | POLLPRI;
do {
n = poll(&pfd, 1, 1000);
pfd.events = POLLIN | POLLPRI;
do {
n = poll(&pfd, 1, 1000);
- } while (n == -1 && errno == EINTR);
+ } while (n == -1 && errno == EINTR && !got_sigterm);
for (done = 0; done < count; ) {
nb = read(fd, ptr, count - done);
if (nb < 0) {
for (done = 0; done < count; ) {
nb = read(fd, ptr, count - done);
if (nb < 0) {
+ if (errno == EINTR && !got_sigterm)