Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for NoMMU #297

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SHELL=bash
CFLAGS=-std=gnu99 -static -s -Wall -Werror -O3
CFLAGS_AUTO=-std=gnu99 -static-pie -s -Wall -Werror -O3

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

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

.PHONY: build
build: VERSION.h
$(CC) $(CFLAGS) -o dumb-init dumb-init.c
$(CC) $(CFLAGS_AUTO) $(CFLAGS) -o dumb-init dumb-init.c

VERSION.h: VERSION
echo '// THIS FILE IS AUTOMATICALLY GENERATED' > VERSION.h
Expand Down
10 changes: 6 additions & 4 deletions dumb-init.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,9 @@ int main(int argc, char *argv[]) {
}
}

child_pid = fork();
child_pid = vfork();
if (child_pid < 0) {
PRINTERR("Unable to fork. Exiting.\n");
PRINTERR("Unable to vfork. Exiting.\n");
return 1;
} else if (child_pid == 0) {
/* child */
Expand All @@ -306,7 +306,7 @@ int main(int argc, char *argv[]) {
errno,
strerror(errno)
);
exit(1);
_exit(1);
}

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

// if this point is reached, exec failed, so we should exit nonzero
PRINTERR("%s: %s\n", cmd[0], strerror(errno));
return 2;
_exit(2);
} else {
/* parent */
DEBUG("Child spawned with PID %d.\n", child_pid);
Expand All @@ -337,4 +337,6 @@ int main(int argc, char *argv[]) {
handle_signal(signum);
}
}

return 1;
}