Ken Van Hoeylandt f8172446fd
App loading improvements and more (#675)
- External apps can opt into automatic cleanup when they exit, including tracked tasks, threads, files, directories, and memory.
- App-relative file paths resolve against the app’s working directory, with `.` and `..` normalized.
- The shell identifies ELF binaries that cannot be executed instead of treating them as scripts.
- Shared icon fonts now offer distinct default and large sizes, with updated icons across the interface.
- ESP32 apps can load additional ELF formats when address mirroring is enabled.
- Terminal colors render clearly on monochrome displays, and toolbar buttons have cleaner styling.
- GPS settings safely refresh their device list when their window is hidden or its widgets are destroyed.
2026-10-06 07:45:58 +02:00

50 lines
1.2 KiB
C++

// SPDX-License-Identifier: Apache-2.0
#include <dirent.h>
#include <fcntl.h>
#include <pthread.h>
#include <unistd.h>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
namespace {
void* run_forever(void*) {
while (true) {
sleep(1);
}
return nullptr;
}
} // namespace
// Leaks an fd, a FILE, a DIR and memory, and writes their fds to argv[1].
// With "thread" as argv[2], it also leaves a thread running.
extern "C" int32_t main(int argc, char* argv[]) {
if (argc < 2) {
return 1;
}
const int fd = open("/dev/null", O_RDONLY);
FILE* file = fopen("/dev/null", "r");
DIR* dir = opendir("/");
void* memory = malloc(64);
if (fd < 0 || file == nullptr || dir == nullptr || memory == nullptr) {
return 2;
}
if (argc > 2 && strcmp(argv[2], "thread") == 0) {
pthread_t thread;
if (pthread_create(&thread, nullptr, run_forever, nullptr) != 0) {
return 3;
}
}
FILE* output = fopen(argv[1], "w");
if (output == nullptr) {
return 4;
}
fprintf(output, "%d %d %d", fd, fileno(file), dirfd(dir));
fclose(output);
return 0;
}