Browse Source

bug fix and using musl-gcc

master
Ralph Rönnquist 8 months ago
parent
commit
107009a277
  1. 24
      src/Makefile
  2. 26
      src/reaper.c

24
src/Makefile

@ -1,22 +1,10 @@
all: reaper reaperc reapernsl
all: reaper
STRIP?=strip
CC = musl-gcc
CFLAGS = -Wall -static -O3 -flto
reaper: reaper.asm
fasm $^ -s $@.fas $@
chmod a+x $@
reaper.map: reaper
./fas2txt.lsp $@.fas > $@.map
reaperc: reaper.c
$(CC) -O3 -flto -o $@ $^
$(STRIP) $@
reapernsl: reaper_nsl.c
#$(CC) -O3 -flto -nostdlib -static -fdata-sections -ffunction-sections -o $@ $^ -Wl,--gc-sections -Wl,--strip-all -Wl,--build-id=none
$(CC) -O3 -flto -nostdlib -static -o $@ $^ -Wl,--build-id=none
$(STRIP) --remove-section=.comment $@
reaper: reaper.c
$(CC) $(CFLAGS) -o $@ $^
clean:
rm -f reaper reaperc reaper.fas reaper.map reapernsl
rm -f reaper

26
src/reaper.c

@ -1,19 +1,21 @@
#include <errno.h>
/**
* This program waits for child process and "reaps" them, i.e. read
* off their status so that they can terminate. The program exits when
* it runs out of children.
*/
#include <signal.h>
#include <string.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/types.h>
int main(void) {
sigset_t set;
siginfo_t status;
sigset_t set;
siginfo_t status;
if (getpid()!=1)
return 1;
sigfillset(&set);
sigprocmask(SIG_BLOCK,&set,NULL);
memset(&status,0,sizeof status);
while (-ECHILD!=waitid(P_ALL,0,&status,WEXITED));
return 1;
sigfillset(&set);
sigprocmask(SIG_BLOCK,&set,NULL);
do {
memset( &status, 0, sizeof( status ) );
} while ( waitid( P_ALL, 0, &status, WEXITED ) == 0 );
return 0;
}

Loading…
Cancel
Save