diff -r 139df1ee9854 -r d78a152554c4 libpurple/protocols/zephyr/zephyr.c --- a/libpurple/protocols/zephyr/zephyr.c Wed Dec 03 01:58:45 2008 +0000 +++ b/libpurple/protocols/zephyr/zephyr.c Sat Dec 13 05:45:27 2008 +0000 @@ -64,7 +64,7 @@ PURPLE_ZEPHYR_NONE, /* Non-kerberized ZEPH0.2 */ PURPLE_ZEPHYR_KRB4, /* ZEPH0.2 w/ KRB4 support */ PURPLE_ZEPHYR_TZC, /* tzc executable proxy */ - PURPLE_ZEPHYR_INTERGALACTIC_KRB4, /* Kerberized ZEPH0.3 */ + PURPLE_ZEPHYR_INTERGALACTIC_KRB4 /* Kerberized ZEPH0.3 */ } zephyr_connection_type; struct _zephyr_account { @@ -1630,27 +1630,21 @@ gboolean found_ps = FALSE; gchar ** tzc_cmd_array = g_strsplit(purple_account_get_string(gc->account,"tzc_command","/usr/bin/tzc -e %s")," ",0); if (close(1) == -1) { - purple_debug_error("zephyr", "stdout couldn't be closed. dying\n"); exit(-1); } if (dup2(zephyr->fromtzc[1], 1) == -1) { - purple_debug_error("zephyr", "dup2 of stdout failed \n"); exit(-1); } if (close(zephyr->fromtzc[1]) == -1) { - purple_debug_error("zephyr", "closing of piped stdout failed\n"); exit(-1); } if (close(0) == -1) { - purple_debug_error("zephyr", "stdin couldn't be closed. dying\n"); exit(-1); } if (dup2(zephyr->totzc[0], 0) == -1) { - purple_debug_error("zephyr", "dup2 of stdin failed \n"); exit(-1); } if (close(zephyr->totzc[0]) == -1) { - purple_debug_error("zephyr", "closing of piped stdin failed\n"); exit(-1); } /* tzc_command should really be of the form @@ -1674,11 +1668,11 @@ } if (!found_ps) { - purple_connection_error(gc,"Tzc command needs %s to set the exposure\n"); - return; + exit(-1); } execvp(tzc_cmd_array[0], tzc_cmd_array); + exit(-1); } else { fd_set rfds; @@ -1690,6 +1684,7 @@ int parenlevel=0; char* tempstr; int tempstridx; + int select_status; zephyr->tzc_pid = pid; /* wait till we have data to read from ssh */ @@ -1701,11 +1696,19 @@ purple_debug_info("zephyr", "about to read from tzc\n"); - select(zephyr->fromtzc[ZEPHYR_FD_READ] + 1, &rfds, NULL, NULL, NULL); + if (waitpid(pid, NULL, WNOHANG) == 0) { /* Only select if tzc is still running */ + purple_debug_info("zephyr", "about to read from tzc\n"); + select_status = select(zephyr->fromtzc[ZEPHYR_FD_READ] + 1, &rfds, NULL, NULL, NULL); + } + else { + purple_debug_info("zephyr", "tzc exited early\n"); + select_status = -1; + } FD_ZERO(&rfds); FD_SET(zephyr->fromtzc[ZEPHYR_FD_READ], &rfds); - while (select(zephyr->fromtzc[ZEPHYR_FD_READ] + 1, &rfds, NULL, NULL, &tv)) { + while (select_status > 0 && + select(zephyr->fromtzc[ZEPHYR_FD_READ] + 1, &rfds, NULL, NULL, &tv) > 0) { read(zephyr->fromtzc[ZEPHYR_FD_READ], bufcur, 1); bufcur++; if ((bufcur - buf) > (bufsize - 1)) {