diff options
-rw-r--r-- | multi_auth.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/multi_auth.c b/multi_auth.c index 1160491..9140036 100644 --- a/multi_auth.c +++ b/multi_auth.c @@ -102,24 +102,23 @@ static int perform_auth(void) #undef STACK_SIZE } - for (int i = 0; i < countof(modules_g); ++i) { - int status; - - do { - waitpid(-1, &status, 0); + siginfo_t infos; - } while (!WIFEXITED(status) && !WIFSIGNALED(status)); + /* wait for a first child to exit or be killed */ + waitid(P_ALL, 0, &infos, WEXITED); - if (WIFEXITED(status)) { - for (int j = 0; j < countof(modules_g); ++j) { - kill(modules_g[j].pid, SIGKILL); - } + int ret = infos.si_status; - return (WEXITSTATUS(status) == 0) ? PAM_SUCCESS : PAM_AUTH_ERR; + for (int i = 0; i < countof(modules_g); ++i) { + if (modules_g[i].pid == infos.si_pid) { + continue; } + + kill(modules_g[i].pid, SIGKILL); + waitpid(modules_g[i].pid, NULL, 0); } - return PAM_AUTH_ERR; + return ret; } PAM_EXTERN |