From: Ralph Ronnquist Date: Wed, 30 Mar 2022 06:04:20 +0000 (+1100) Subject: bug fix and using musl-gcc X-Git-Tag: deb_0.1.3~5^2~1 X-Git-Url: https://git.rrq.au/?a=commitdiff_plain;h=107009a27770dc0c617bfe80442336d54aee445b;p=rrq%2Foverlay-boot.git bug fix and using musl-gcc --- diff --git a/src/Makefile b/src/Makefile index 82cffb0..5c8c757 100644 --- a/src/Makefile +++ b/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 diff --git a/src/reaper.c b/src/reaper.c index f1c2f9a..9da2124 100644 --- a/src/reaper.c +++ b/src/reaper.c @@ -1,19 +1,21 @@ -#include +/** + * 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 #include -#include #include -#include 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; }