alloc: reduce number of large pages to 256.
[ccan] / tools / tools.c
index 5db43df08b20ed8b45139055ee42c58d463322cc..8ce193cd226bd0905f7a6738c4f70eda4057fe1c 100644 (file)
@@ -99,7 +99,6 @@ static char *run_with_timeout(const void *ctx,
                    || open("/dev/null", O_RDONLY) != STDIN_FILENO)
                        exit(128);
 
                    || open("/dev/null", O_RDONLY) != STDIN_FILENO)
                        exit(128);
 
-               setpgid(0, 0);
                signal(SIGALRM, killme);
                itim.it_interval.tv_sec = itim.it_interval.tv_usec = 0;
                itim.it_value.tv_sec = *timeout_ms / 1000;
                signal(SIGALRM, killme);
                itim.it_interval.tv_sec = itim.it_interval.tv_usec = 0;
                itim.it_value.tv_sec = *timeout_ms / 1000;
@@ -199,6 +198,18 @@ char *temp_file(const void *ctx, const char *extension)
        return talloc_asprintf(ctx, "%s/%u%s", tmpdir, count++, extension);
 }
 
        return talloc_asprintf(ctx, "%s/%u%s", tmpdir, count++, extension);
 }
 
+char *maybe_temp_file(const void *ctx, const char *extension, bool keep,
+                     const char *srcname)
+{
+       size_t baselen;
+
+       if (!keep)
+               return temp_file(ctx, extension);
+
+       baselen = strrchr(srcname, '.') - srcname;
+       return talloc_asprintf(ctx, "%.*s%s", baselen, srcname, extension);
+}
+
 bool move_file(const char *oldname, const char *newname)
 {
        char *contents;
 bool move_file(const char *oldname, const char *newname)
 {
        char *contents;