From: Lennart Poettering Date: Mon, 19 Nov 2018 19:47:46 +0000 (+0100) Subject: main-func: automatically call static destructors from main-func.h macros X-Git-Tag: v240~275^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8a4fdaf2921db52e46b800b6540f8e99853b556f;p=thirdparty%2Fsystemd.git main-func: automatically call static destructors from main-func.h macros --- diff --git a/src/basic/main-func.h b/src/basic/main-func.h index 9ebe0ab8821..caa5885e8b0 100644 --- a/src/basic/main-func.h +++ b/src/basic/main-func.h @@ -3,12 +3,15 @@ #include +#include "static-destruct.h" + /* Negative return values from impl are mapped to EXIT_FAILURE, and * everything else means success! */ #define DEFINE_MAIN_FUNCTION(impl) \ int main(int argc, char *argv[]) { \ int r; \ r = impl(argc, argv); \ + static_destruct(); \ return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; \ } @@ -19,5 +22,6 @@ int main(int argc, char *argv[]) { \ int r; \ r = impl(argc, argv); \ + static_destruct(); \ return r != 0 ? EXIT_FAILURE : EXIT_SUCCESS; \ }