2024-08-25 15:26:45 +00:00
|
|
|
#define die(...) {fprintf(stderr,"file %s,line %d\n",__FILE__,__LINE__);die_func(__VA_ARGS__);}
|
2024-06-22 18:54:21 +00:00
|
|
|
void remove_cgroup();
|
2024-06-20 16:41:25 +00:00
|
|
|
|
2024-08-25 15:26:45 +00:00
|
|
|
static void die_func(const char *fmt, ...)
|
2024-06-20 16:41:25 +00:00
|
|
|
{
|
|
|
|
va_list params;
|
|
|
|
va_start(params, fmt);
|
|
|
|
vfprintf(stderr, fmt, params);
|
2024-08-25 15:26:45 +00:00
|
|
|
puts("\n");
|
2024-06-20 16:41:25 +00:00
|
|
|
va_end(params);
|
2024-06-22 18:54:21 +00:00
|
|
|
remove_cgroup();
|
2024-06-20 16:41:25 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_file(char* path, char* line)
|
|
|
|
{
|
|
|
|
FILE *f = fopen(path, "w");
|
|
|
|
if (f == NULL) {die("Failed to open file %s: %m\n", path);}
|
|
|
|
if (fwrite(line, 1, strlen(line), f) < 0) {die("Failed to write to file %s:\n", path);}
|
|
|
|
if (fclose(f) != 0) {die("Failed to close file %s: %m\n", path);}
|
|
|
|
}
|