Commit eabed370 authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

bin: clear temporary files on termination signals

This is particularly important for src/tests/satmin.test, where ltl2tgba
might be killed while writing a huge temporary file used for SAT-based
minimization.  Before this patch, the temporary files would remain in
src/tests/satmin.dir/, easily overflowing the 100GB limit of the docker
containers we use on the build farm.

* src/bin/ Catch termination signals for all tools,
even those that do not yet clear temporary files.
* Check for sigaction.
parent 83364c63
......@@ -104,7 +104,7 @@ fi
AC_CHECK_FUNCS([times kill alarm])
AC_CHECK_FUNCS([times kill alarm sigaction])
......@@ -21,6 +21,9 @@
#include "argp.h"
#include <cstdlib>
#include <iostream>
#include <signal.h>
#include <sys/wait.h>
#include "misc/tmpfile.hh"
const char* argp_program_bug_address = "<" PACKAGE_BUGREPORT ">";
......@@ -37,6 +40,33 @@ This is free software: you are free to change and redistribute it.\n\
There is NO WARRANTY, to the extent permitted by law.\n", stream);
static void sig_handler(int sig)
// Send the signal again, this time to the default handler, so that
// we return a meaningful error code.
static void setup_sig_handler()
struct sigaction sa;
sa.sa_handler = sig_handler;
sa.sa_flags = SA_RESETHAND;
// Catch termination signals, so we can cleanup temporary files.
sigaction(SIGALRM, &sa, 0);
sigaction(SIGHUP, &sa, 0);
sigaction(SIGINT, &sa, 0);
sigaction(SIGPIPE, &sa, 0);
sigaction(SIGQUIT, &sa, 0);
sigaction(SIGTERM, &sa, 0);
# define setup_sig_handler() while (0);
setup(char** argv)
......@@ -50,6 +80,8 @@ setup(char** argv)
argp_err_exit_status = 2;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment