+static void sandbox_parent_own_orbit_dir_cleanup_atexit(void)
+{
+static gboolean done=FALSE;
+
+ if (done)
+ return;
+ done=TRUE;
+
+ unlink_nonrecursive(sandbox_parent_own_orbit_dir);
+}
+
+static struct sandbox_parent_own_orbit_dir_cleanup_signal {
+ int signum;
+ /* FIXME: Why we cannot use 'sighandler_t'? */ void (*sighandler_orig)(int signum);
+ } sandbox_parent_own_orbit_dir_cleanup_signals[]={
+ { SIGINT },
+ { SIGQUIT },
+ { SIGTERM },
+ { SIGHUP },
+ { SIGABRT },
+ { SIGFPE },
+ };
+
+static void sandbox_parent_own_orbit_dir_cleanup_sighandler(int signum)
+{
+struct sandbox_parent_own_orbit_dir_cleanup_signal *sigstructp;
+
+ sandbox_parent_own_orbit_dir_cleanup_atexit();
+
+ for (
+ sigstructp=sandbox_parent_own_orbit_dir_cleanup_signals;
+ sigstructp<sandbox_parent_own_orbit_dir_cleanup_signals+G_N_ELEMENTS(sandbox_parent_own_orbit_dir_cleanup_signals);
+ sigstructp++) {
+ if (sigstructp->signum==signum)
+ break;
+ }
+ g_assert(sigstructp<sandbox_parent_own_orbit_dir_cleanup_signals+G_N_ELEMENTS(sandbox_parent_own_orbit_dir_cleanup_signals));
+ signal(signum,sigstructp->sighandler_orig);
+ raise(signum);
+}
+
+static void sandbox_parent_own_orbit_dir_cleanup_init(void)
+{
+struct sandbox_parent_own_orbit_dir_cleanup_signal *sigstructp;
+
+ g_atexit(sandbox_parent_own_orbit_dir_cleanup_atexit);
+ for (
+ sigstructp=sandbox_parent_own_orbit_dir_cleanup_signals;
+ sigstructp<sandbox_parent_own_orbit_dir_cleanup_signals+G_N_ELEMENTS(sandbox_parent_own_orbit_dir_cleanup_signals);
+ sigstructp++) {
+ sigstructp->sighandler_orig=signal(sigstructp->signum,sandbox_parent_own_orbit_dir_cleanup_sighandler);
+ if (sigstructp->sighandler_orig==SIG_IGN)
+ sigstructp->sighandler_orig=SIG_DFL;
+ }
+}
+