mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-04 10:18:31 +00:00
Mint APE Loader v1.5
This change ports APE Loader to Linux AARCH64, so that Raspberry Pi users can run programs like redbean, without the executable needing to modify itself. Progress has also slipped into this change on the issue of making progress better conforming to user expectations and industry standards regarding which symbols we're allowed to declare
This commit is contained in:
parent
6843150e0c
commit
7e0a09feec
510 changed files with 1783 additions and 1483 deletions
|
@ -263,14 +263,14 @@ void RequireRoot(void) {
|
|||
|
||||
void ListenForTerm(void) {
|
||||
struct sigaction sa = {.sa_handler = OnTerm};
|
||||
_npassert(!sigaction(SIGTERM, &sa, 0));
|
||||
_npassert(!sigaction(SIGHUP, &sa, 0));
|
||||
_npassert(!sigaction(SIGINT, &sa, 0));
|
||||
npassert(!sigaction(SIGTERM, &sa, 0));
|
||||
npassert(!sigaction(SIGHUP, &sa, 0));
|
||||
npassert(!sigaction(SIGINT, &sa, 0));
|
||||
}
|
||||
|
||||
void AutomaticallyHarvestZombies(void) {
|
||||
struct sigaction sa = {.sa_handler = SIG_IGN, .sa_flags = SA_NOCLDWAIT};
|
||||
_npassert(!sigaction(SIGCHLD, &sa, 0));
|
||||
npassert(!sigaction(SIGCHLD, &sa, 0));
|
||||
}
|
||||
|
||||
void FindFirewall(void) {
|
||||
|
@ -305,9 +305,9 @@ void Daemonize(void) {
|
|||
|
||||
void UseLog(void) {
|
||||
if (g_logfd > 0) {
|
||||
_npassert(dup2(g_logfd, 2) == 2);
|
||||
npassert(dup2(g_logfd, 2) == 2);
|
||||
if (g_logfd != 2) {
|
||||
_npassert(!close(g_logfd));
|
||||
npassert(!close(g_logfd));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -338,7 +338,7 @@ void WritePid(void) {
|
|||
LOG("error: open(%#s) failed: %s", g_pidname, strerror(errno));
|
||||
_Exit(4);
|
||||
}
|
||||
_npassert((rc = pread(fd, buf, 11, 0)) != -1);
|
||||
npassert((rc = pread(fd, buf, 11, 0)) != -1);
|
||||
if (rc) {
|
||||
pid = atoi(buf);
|
||||
LOG("killing old blackholed process %d", pid);
|
||||
|
@ -358,9 +358,9 @@ void WritePid(void) {
|
|||
}
|
||||
}
|
||||
FormatInt32(buf, getpid());
|
||||
_npassert(!ftruncate(fd, 0));
|
||||
_npassert((rc = pwrite(fd, buf, strlen(buf), 0)) == strlen(buf));
|
||||
_npassert(!close(fd));
|
||||
npassert(!ftruncate(fd, 0));
|
||||
npassert((rc = pwrite(fd, buf, strlen(buf), 0)) == strlen(buf));
|
||||
npassert(!close(fd));
|
||||
}
|
||||
|
||||
bool IsMyIp(uint32_t ip) {
|
||||
|
|
|
@ -656,8 +656,8 @@ void *NewSafeBuffer(size_t n) {
|
|||
char *p;
|
||||
long pagesize = sysconf(_SC_PAGESIZE);
|
||||
size_t m = ROUNDUP(n, pagesize);
|
||||
_npassert((p = valloc(m + pagesize)));
|
||||
_npassert(!mprotect(p + m, pagesize, PROT_NONE));
|
||||
npassert((p = valloc(m + pagesize)));
|
||||
npassert(!mprotect(p + m, pagesize, PROT_NONE));
|
||||
return p;
|
||||
}
|
||||
|
||||
|
@ -666,7 +666,7 @@ void FreeSafeBuffer(void *p) {
|
|||
long pagesize = sysconf(_SC_PAGESIZE);
|
||||
size_t n = malloc_usable_size(p);
|
||||
size_t m = ROUNDDOWN(n, pagesize);
|
||||
_npassert(!mprotect(p, m, PROT_READ | PROT_WRITE));
|
||||
npassert(!mprotect(p, m, PROT_READ | PROT_WRITE));
|
||||
free(p);
|
||||
}
|
||||
|
||||
|
@ -1947,9 +1947,9 @@ int main(int argc, char *argv[]) {
|
|||
if (closefrom(0))
|
||||
for (int i = 0; i < 256; ++i) //
|
||||
close(i);
|
||||
_npassert(0 == open(_PATH_DEVNULL, O_RDWR));
|
||||
_npassert(1 == dup(0));
|
||||
_npassert(2 == open("turfwar.log", O_CREAT | O_WRONLY | O_APPEND, 0644));
|
||||
npassert(0 == open(_PATH_DEVNULL, O_RDWR));
|
||||
npassert(1 == dup(0));
|
||||
npassert(2 == open("turfwar.log", O_CREAT | O_WRONLY | O_APPEND, 0644));
|
||||
}
|
||||
|
||||
LOG("Generating Hilbert Curve...\n");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue