# HG changeset patch # User Mikael Berthe # Date 1442950200 -7200 # Node ID e62319868844fa367dbe0a28096446fa883b4936 # Parent 09508eeb81dc489262b4b7251cbbecc70e52f3dd Fix external password support (esp. on OS X) pclose() can return -1 and set errno to ECHILD if the process has already terminated. Thanks to languitar for the report and troubleshooting. diff -r 09508eeb81dc -r e62319868844 mcabber/mcabber/main.c --- a/mcabber/mcabber/main.c Sat Sep 05 18:28:12 2015 +0200 +++ b/mcabber/mcabber/main.c Tue Sep 22 21:30:00 2015 +0200 @@ -30,6 +30,7 @@ #include #include #include +#include #include "caps.h" #include "screen.h" @@ -175,22 +176,29 @@ char *pwd; FILE *outfp = popen(command, "r"); if (outfp == NULL) { - scr_log_print(LPRINT_NORMAL, "** ERROR: Failed to execute password_eval command."); + scr_log_print(LPRINT_NORMAL, + "** ERROR: Failed to execute password_eval command."); *status = -1; return NULL; } pwd = g_new0(char, MAX_PWD); if (fgets(pwd, MAX_PWD, outfp) == NULL) { - scr_log_print(LPRINT_NORMAL, "** ERROR: Failed to read from password_eval command."); + scr_log_print(LPRINT_NORMAL, + "** ERROR: Failed to read from password_eval command."); g_free(pwd); *status = -1; return NULL; } int res = pclose(outfp); - if (res != 0) { - scr_log_print(LPRINT_NORMAL, "** ERROR: Password evaluation command exited with error %d.", res); + if (res != 0 && errno != ECHILD) { + scr_log_print(LPRINT_NORMAL, + "** ERROR: Password evaluation command exited with error %d.", + res); + if (res == -1) { + scr_log_print(LPRINT_NORMAL, " errno=%d", errno); + } g_free(pwd); *status = res; return NULL;