Skip to content

Commit 085fc15

Browse files
committed
Add support for NoMMU
1 parent 5ccca9c commit 085fc15

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
SHELL=bash
2-
CFLAGS=-std=gnu99 -static -s -Wall -Werror -O3
2+
CFLAGS_AUTO=-std=gnu99 -static-pie -s -Wall -Werror -O3
33

44
TEST_PACKAGE_DEPS := build-essential python python-pip procps python-dev python-setuptools
55

@@ -8,7 +8,7 @@ VERSION = $(shell cat VERSION)
88

99
.PHONY: build
1010
build: VERSION.h
11-
$(CC) $(CFLAGS) -o dumb-init dumb-init.c
11+
$(CC) $(CFLAGS_AUTO) $(CFLAGS) -o dumb-init dumb-init.c
1212

1313
VERSION.h: VERSION
1414
echo '// THIS FILE IS AUTOMATICALLY GENERATED' > VERSION.h

dumb-init.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,9 @@ int main(int argc, char *argv[]) {
292292
}
293293
}
294294

295-
child_pid = fork();
295+
child_pid = vfork();
296296
if (child_pid < 0) {
297-
PRINTERR("Unable to fork. Exiting.\n");
297+
PRINTERR("Unable to vfork. Exiting.\n");
298298
return 1;
299299
} else if (child_pid == 0) {
300300
/* child */
@@ -306,7 +306,7 @@ int main(int argc, char *argv[]) {
306306
errno,
307307
strerror(errno)
308308
);
309-
exit(1);
309+
_exit(1);
310310
}
311311

312312
if (ioctl(STDIN_FILENO, TIOCSCTTY, 0) == -1) {
@@ -322,7 +322,7 @@ int main(int argc, char *argv[]) {
322322

323323
// if this point is reached, exec failed, so we should exit nonzero
324324
PRINTERR("%s: %s\n", cmd[0], strerror(errno));
325-
return 2;
325+
_exit(2);
326326
} else {
327327
/* parent */
328328
DEBUG("Child spawned with PID %d.\n", child_pid);
@@ -337,4 +337,6 @@ int main(int argc, char *argv[]) {
337337
handle_signal(signum);
338338
}
339339
}
340+
341+
return 1;
340342
}

0 commit comments

Comments
 (0)