diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c index ed49163..80cc0eb 100644 --- a/plugins/check_smtp.c +++ b/plugins/check_smtp.c @@ -129,6 +129,9 @@ main (int argc, char **argv) char *error_msg = ""; struct timeval tv; + /* catch pipe errors in read.write */ + (void) signal (SIGPIPE, SIG_IGN); + setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); @@ -662,8 +665,20 @@ void smtp_quit(void) { int bytes; + int n; + + n = my_send(SMTP_QUIT, strlen(SMTP_QUIT)); + if(n != 0) { + if(verbose) { + /* Not sure this is really an unknown state so just print out instead + die (STATE_UNKNOWN, + */ + printf( + _("Connection was closed by server before we could send QUIT command\n")); + } + return; + } - my_send(SMTP_QUIT, strlen(SMTP_QUIT)); if (verbose) printf(_("sent %s\n"), "QUIT");