repo: tlswrap action: commit revision: path_from: revision_from: de9a688ffca230618ca779b0b5c434f72a692fa5: path_to: revision_to:
commit de9a688ffca230618ca779b0b5c434f72a692fa5 Author: epochDate: Thu Jun 1 21:08:53 2023 +0000 added subprocess cleanup and ignore a set of errors diff --git a/tlswrap.c b/tlswrap.c
--- a/tlswrap.c +++ b/tlswrap.c @@ -4,6 +4,7 @@ #include#include +#include // waitpid #include #include @@ -538,6 +539,9 @@ int main(int argc,char *argv[]) { } //now, let's try harder on these error messages. err_err = ERR_get_error(); //??? + if(errno == 0) {//good nuff?y + return 1; + } syslog(LOG_DAEMON|LOG_ERR,"%s -> %s SSL_accept() failed. %d / %d / %d / %s / %s / %d / %s", ru, @@ -682,6 +686,22 @@ int main(int argc,char *argv[]) { SSL_shutdown(ssl); SSL_free(ssl); EVP_cleanup(); + int status; + if(waitpid(child,&status,WNOHANG) == child) { + syslog(LOG_DAEMON|LOG_DEBUG,"child process exited as it should :)"); + return 0; + } + syslog(LOG_DAEMON|LOG_WARNING,"waitpid: %s",strerror(errno)); + if(kill(child,SIGTERM)) { //if the process hasn't exited already, let's try to kill it. + syslog(LOG_DAEMON|LOG_WARNING,"kill: %s",strerror(errno)); + } + sleep(5); + if(waitpid(child,&status,WNOHANG) == child) { + syslog(LOG_DAEMON|LOG_WARNING,"child process exited after a SIGTERM and a 5s wait."); + return 0; + } + syslog(LOG_DAEMON|LOG_CRIT,"waitpid: %s",strerror(errno)); + return 0; }
-----END OF PAGE-----