compiler.h \
error.h \
initutils.c initutils.h \
+ memory_utils.h \
parse.c parse.h \
raw_syscalls.c raw_syscalls.h \
string_utils.c string_utils.h
file_utils.c file_utils.h \
log.c log.h \
macro.h \
+ memory_utils.h \
namespace.c namespace.h \
string_utils.c string_utils.h
#include "config.h"
#include "error.h"
#include "initutils.h"
+#include "memory_utils.h"
#include "parse.h"
#include "raw_syscalls.h"
#include "string_utils.h"
static void prevent_forking(void)
{
- FILE *f;
- size_t len = 0;
- char *line = NULL;
+ __do_free char *line = NULL;
+ __do_fclose FILE *f = NULL;
char path[PATH_MAX];
+ size_t len = 0;
f = fopen("/proc/self/cgroup", "r");
if (!f)
if (ret < 0 || (size_t)ret >= sizeof(path)) {
if (my_args.quiet)
fprintf(stderr, "Failed to create string\n");
- goto on_error;
+ return;
}
fd = open(path, O_WRONLY);
if (fd < 0) {
if (my_args.quiet)
fprintf(stderr, "Failed to open \"%s\"\n", path);
- goto on_error;
+ return;
}
ret = write(fd, "1", 1);
fprintf(stderr, "Failed to write to \"%s\"\n", path);
close(fd);
- break;
+ return;
}
-
-on_error:
- free(line);
- fclose(f);
}
static void kill_children(pid_t pid)
{
- FILE *f;
+ __do_fclose FILE *f = NULL;
char path[PATH_MAX];
int ret;
if (fscanf(f, "%d ", &find_pid) != 1) {
if (my_args.quiet)
fprintf(stderr, "Failed to retrieve pid\n");
- fclose(f);
return;
}
(void)kill_children(find_pid);
(void)kill(find_pid, SIGKILL);
}
-
- fclose(f);
}
static void remove_self(void)